按配置文件属性排列的 asp.net 用户列表

发布于 2024-12-09 11:31:43 字数 316 浏览 0 评论 0原文

我已经为新用户添加到我们的系统时创建了一些配置文件属性。

一个属性称为“客户端”,并将该用户链接到特定客户端并存储客户端 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。

I have created some profile properties for when a new user is added to our system.

One property is called 'Client' and links this user to a particular client and stores a client id.

I am trying to create a page that shows a list of users for each client on the system such as:

Client 1
   User 1
   User 2
   User 3
Client 2
   User 4
   User 5
   User 6
Client 3
   User 7
   User 8
   User 9

Is there a way to get a list of users that match a particular profile property?

Thanks for any help. J.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

甜柠檬 2024-12-16 11:31:43

下面的代码是我编写的一个旧的 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

The code below is an old VB.Net method I wrote to filter users based on a profile value. It could be slightly modified to accomplish your task.

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
浴红衣 2024-12-16 11:31:43

找到了我正在寻找的东西,最终使用了这个:
http://pretzelsteelersfan.blogspot.com/2007 /03/get-aspnet-profile-properties-from-sql.html

不过,感谢您的帮助。

Found what i was looking for, ended up using this:
http://pretzelsteelersfan.blogspot.com/2007/03/get-aspnet-profile-properties-from-sql.html

Thanks for any help though.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文