asp.net按配置文件属性列出的用户列表
我已经创建了一些配置文件属性,以便在系统中添加新用户时使用 一个属性称为“客户端”,将此用户链接到特定客户端并存储客户端id 我正在尝试创建一个页面,其中显示系统上每个客户端的用户列表,例如:asp.net按配置文件属性列出的用户列表,asp.net,vb.net,asp.net-profiles,Asp.net,Vb.net,Asp.net Profiles,我已经创建了一些配置文件属性,以便在系统中添加新用户时使用 一个属性称为“客户端”,将此用户链接到特定客户端并存储客户端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 是否有方法获取与特定配置文件属性匹配的用户列表 谢谢你的帮助。J.下面
Client 1
User 1
User 2
User 3
Client 2
User 4
User 5
User 6
Client 3
User 7
User 8
User 9
是否有方法获取与特定配置文件属性匹配的用户列表
谢谢你的帮助。J.下面的代码是我编写的一个旧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
函数FindUsers(ByVal prop作为字符串,ByVal val作为字符串)作为列表(ProfileCommon)
“使用通用的人员列表
Dim peeps作为新列表(公共配置文件)()
视图状态(“道具”)=道具
视图状态(“val”)=val
'获取所有配置文件对象
将配置文件按ProfileInfoCollection=ProfileManager.GetAllProfiles(ProfileAuthenticationOption.All)进行调整
“浏览一下个人资料
将每个信息作为配置文件中的配置文件信息
'我们需要将ProfileInfo转换为ProfileCommon
'以访问要执行搜索的属性
Dim userProfile As ProfileCommon=ProfileCommon.Create(info.UserName)
如果Roles.IsUserInRole(info.UserName,“成员订户”),则
“如果生日匹配的话
如果val“”则
如果道具“”也向左(userProfile.Item(道具),val.Length)=val,则
“将它们添加到我们的列表中
添加(用户配置文件)
如果结束
其他的
添加(用户配置文件)
如果结束
如果结束
下一个
如果peeps.Count>0,则显示用户详细信息(peeps(0).UserName)
回望
端函数
找到了我要找的内容,最后使用了以下内容:
感谢您的帮助。谢谢zackg,那时没有内置的解决方案。我会玩一玩,让你知道我的进展如何……再次感谢你。