1

新しいユーザーがシステムに追加されたときのために、いくつかのプロファイルプロパティを作成しました。

1つのプロパティは「クライアント」と呼ばれ、このユーザーを特定のクライアントにリンクし、クライアント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。

4

2 に答える 2

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
于 2011-10-10T22:21:27.820 に答える
1

私が探していたものが見つかり、これを使用することになりました: http://pretzelsteelersfan.blogspot.com/2007/03/get-aspnet-profile-properties-from-sql.html

助けてくれてありがとう。

于 2011-10-11T15:07:12.113 に答える