Monday, October 15, 2007

Getting accountnames from UserProfile Database

It was hard to find a piece of code to retrieve the Accountnames from users who are placed in the userprofile database. I found an example in the MOSS SDK:

using (SPSite site = new SPSite(http://servername/))
{
ServerContext context = ServerContext.GetContext(site);
UserProfileManager profileManager = new UserProfileManager(context);
foreach (UserProfile profile in profileManager)
{
Console.WriteLine(profile[PropertyConstants.AccountName]);
}
}

No comments: