I am looping through a group of UserPrincipal that was retrieved from Active Directory. I need to get find a SPUser using the properties of the UserPrincipal. Once the SPUser is found I will get its UserProfile["PreferredName"].

I have tried passing all of the following to SPUser and the exception says user not found:

  1. UserPrincipal.UserPrincipalName
  2. UserPrincipal.DisplayName

I should also mention the reason I need to find the Preferred Name is because the UserPrincipal.DisplayName that I will eventually pass to a People Picker is resolving as the Preferred Name which I am afraid will mess us up later. I have already synced the Preferred Names, there are just a couple that are stuck as 'domain/username' instead of 'firstname lastname'.

Any ideas?

1 Answer 1


AD users don't exist on SharePoint until something causes SharePoint to know about them (e.g. an explicit permission setting, the user has logged in, etc).

Try using SPWeb.EnsureUser(string userlogonname) - it will create the user within SharePoint if it doesn't already exist, and return the SPUser object.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.