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 want to assign the value from a peopleeditor control to a user field in C#.

I have a resolved entity in the people editor, but when passing the SPUserId into the SPFieldUserValue constructor along with the RootWeb (or even current web), the uservalue is null (i.e. it can't find the user). Is there a way of searching the active directory/the same place the people editor searches for this user as opposed to a SharePoint web?

Thanks a lot.

share|improve this question
up vote 1 down vote accepted

What you are probably missing is a call to EnsureUser, which will create the user if they haven't already visited the website; they don't exist within SharePoint if they haven't been to the website or had permissions explicitly set.

share|improve this answer
Thanks a lot... – JᴀʏMᴇᴇ Sep 20 '12 at 16:08

You need to look to the site instead of the web to find users. Users and groups are all site objects.

share|improve this answer
Thanks a lot mate, appreciate your response. lgaud's answer cracked it for me though. +1. – JᴀʏMᴇᴇ Sep 20 '12 at 16:08

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.