Tuesday, September 22, 2009

How to retrieve account names from UserProfile

It is quite difficult to get accountnames from userprofile database. Using SDK, you can get the account by following example

using (SPSite site = new SPSite(http://portal/))
{
        ServerContext context = ServerContext.GetContext(site);
        UserProfileManager profileManager = new UserProfileManager(context);

        foreach (UserProfile profile in profileManager)
       {
             Console.WriteLine(profile[PropertyConstants.AccountName]);
       }
}

0 comments:

Post a Comment