5

According to the documentation (http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.ensureuser.aspx) the login is created when the provided login does not exist.

From what I have tested so far no account is created when using this method. I simply get an exception which has the message that the user does not exist.

Am I missing something or is the documentation not correct?

1
  • Mu understanding of the documentation is this: if the login has access to the site collection, then the user is added to the site.
    – jpaugh
    Sep 20, 2017 at 15:58

3 Answers 3

5

It does not create a new account, but checks if the account has access to the site. If not and the user is valid, it adds the user to the site permission list of the specifice website

1
  • 1
    You're right. I've checked in List 'User Information List. Am I right that the user account is added to this list but no permissions are assigned? Is there any better way to check whether a user exists in a web?
    – André
    Oct 31, 2013 at 8:43
1

Yes It do not create account. Please refer this: http://razaalimithani.blogspot.com/2013/02/sharepoint-2010-spcontextcurrentwebensu.html

0
0

The MSDN about SPWeb.EnsureUser is correct. Are you sure to run AllowUnsafeUpdates to true while executing SPWeb.EnsureUser on SPWeb object?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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