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 have a big problem. I would like add a user to a list item via SPFieldUserValue. But this user has never used the Sharepoint site before. So I can not select the SPUser-Object of this user from a SPUserCollection.

With the UserProfileManager I can select the profile of the user but I can not convert this profile to a SPFieldUserValue.

Any Ideas?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Use SPWeb.EnsureUser that'll make sure the user exist on the site

share|improve this answer
    
Great it works :-) –  AHO Jul 17 '12 at 15:30
    
Snippet of my solution $upm = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context) $AllProfiles = $upm.GetEnumerator() foreach($profile in $AllProfiles){ $accountName = $profile[[Microsoft.Office.Server.UserProfiles.PropertyConstants]::AccountName].‌​Value $lookupUser = $web.EnsureUser($accountName) } –  AHO Jul 17 '12 at 15:32

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.