我已经为新用户添加到我们的系统时创建了一些配置文件属性。
一个属性称为“客户端”,并将此用户链接到特定客户端并存储客户端ID。
我正在尝试创建一个页面,显示系统中每个客户端的用户列表,例如:
Client 1
User 1
User 2
User 3
Client 2
User 4
User 5
User 6
Client 3
User 7
User 8
User 9
有没有办法获得与特定个人资料属性匹配的用户列表?
感谢您的帮助。学家
答案 0 :(得分:1)
下面的代码是我写的一个旧的VB.Net方法,用于根据配置文件值过滤用户。可以稍加修改以完成您的任务。
Function FindUsers(ByVal prop As String, ByVal val As String) As List(Of ProfileCommon)
' Use a generic list of people
Dim peeps As New List(Of ProfileCommon)()
ViewState("prop") = prop
ViewState("val") = val
' Get all profile objects
Dim profiles As ProfileInfoCollection = ProfileManager.GetAllProfiles(ProfileAuthenticationOption.All)
' Go through the profiles
For Each info As ProfileInfo In profiles
' We need to turn a ProfileInfo into a ProfileCommon
' to access the properties to do the search
Dim userProfile As ProfileCommon = ProfileCommon.Create(info.UserName)
If Roles.IsUserInRole(info.UserName, "Members Subscribers") Then
' If the birthday matches
If val <> "" Then
If prop <> "" AndAlso Left(userProfile.Item(prop), val.Length) = val Then
' Add them to our list
peeps.Add(userProfile)
End If
Else
peeps.Add(userProfile)
End If
End If
Next
If peeps.Count > 0 Then ShowUserDetails(peeps(0).UserName)
Return peeps
End Function
答案 1 :(得分:1)
找到了我想要的东西,结果使用了这个: http://pretzelsteelersfan.blogspot.com/2007/03/get-aspnet-profile-properties-from-sql.html
感谢您的帮助。