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'm writing a PowerShell script that adds users to a SharePoint site. To check if the user exists I'm calling the EnsureUser. But my issue is that the when calling this method with a ldap membership provider(Microsoft.Office.Server.Security.LdapMembershipProvider) (i:0#.f|ldapmembership|username) it always returns a user even the user do not exists in Active Directory. So I'm able to add uses that do not exists.

share|improve this question
Are you using AD Groups? – Hugh Wood Nov 29 '12 at 11:07
Yes we are using the LdapRoleProvider for groups, but this script is adding users. – gaotter Nov 29 '12 at 11:32
Are you checking the user like this? SPWeb.EnsureUser(i:0#.f|ad_membership|user) (A code sample from you might help in this case) – Hugh Wood Nov 29 '12 at 11:42
Yes. $web = Get-SpWeb <url>;$user = $web.EnsureUser(i:0#.f|ldapmembership|username); #No exception even user does not exists i source. – gaotter Nov 30 '12 at 9:05
Are the AD groups nested at all? Nested groups can't be read for permissions by all functions. – Hugh Wood Nov 30 '12 at 9:19

Your Answer


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

Browse other questions tagged or ask your own question.