AudienceManager.GetUserAudienceIDs method (String, Boolean, SPWeb)

Gets a list of audience globally unique identifiers (GUIDs) for the specified user name.

Namespace:  Microsoft.Office.Server.Audience
Assembly:  Microsoft.Office.Server.UserProfiles (in Microsoft.Office.Server.UserProfiles.dll)

Syntax

'Declaration
Public Function GetUserAudienceIDs ( _
    accountName As String, _
    needAudienceName As Boolean, _
    web As SPWeb _
) As ArrayList
'Usage
Dim instance As AudienceManager
Dim accountName As String
Dim needAudienceName As Boolean
Dim web As SPWeb
Dim returnValue As ArrayList

returnValue = instance.GetUserAudienceIDs(accountName, _
    needAudienceName, web)
public ArrayList GetUserAudienceIDs(
    string accountName,
    bool needAudienceName,
    SPWeb web
)

Parameters

  • accountName
    Type: System.String

    Microsoft Windows NT account name of a user. Contains both the domain and the user name. For example, Domain\user_name.

  • needAudienceName
    Type: System.Boolean

    True if the AudienceName should be loaded, otherwise, false.

Return value

Type: System.Collections.ArrayList
System.Collections.ArrayList object that represents a list of GUIDs for audiences for the specified user name and site.

Remarks

The GetUserAudienceIDs method retrieves account information for the user with the specified Windows NT user name. Account information such as user name and domain are used to retrieve audience information from the database.

Examples

The following code example shows how to use the GetUserAudienceIDs method to retrieve and list GUIDs for the audiences to which the specified user belongs.

AudienceManager AudMgr = new AudienceManager();
ArrayList IDList = AudMgr.GetUserAudienceIDs("DomainName\\user_name");
System.Console.WriteLine("User Audience GUIDs");

for (int info=0; info<IDList.Count; info++)
{
    System.Console.WriteLine(((Guid)IDList[info]).ToString());
}
Dim AudMgr As New AudienceManager()
Dim IDList As ArrayList = AudMgr.GetUserAudienceIDs("DomainName\\user_name")
System.Console.WriteLine("User Audience GUIDs")

For info As Integer = 0 To IDList.Count - 1
    System.Console.WriteLine((CType(IDList(info), Guid)).ToString())
Next info

See also

Reference

AudienceManager class

AudienceManager members

GetUserAudienceIDs overload

Microsoft.Office.Server.Audience namespace