Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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
add comment

2 Answers 2

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. http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.ensureuser.aspx

share|improve this answer
    
Thanks a lot... –  DeeMac Sep 20 '12 at 16:08
add comment

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. –  DeeMac Sep 20 '12 at 16:08
add comment

Your Answer

 
discard

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.