SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 1 down vote accepted

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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