I'm attempting to find a User by username in Active Directory.
This works:
const string Domain = "SLO1.Foo.Bar.biz";
const string Username = "sanderso";
PrincipalContext principalContext = new PrincipalContext(ContextType.Domain, Domain);
UserPrincipal userPrincipal = UserPrincipal.FindByIdentity(principalContext, Username);
This does not:
const string Domain = "SLO1.Foo.Bar.biz";
const string Container = "CN=Users,DC=SLO1,DC=Foo,DC=Bar,DC=biz";
const string Username = "sanderso";
PrincipalContext principalContext = new PrincipalContext(ContextType.Domain, Domain, Container);
UserPrincipal userPrincipal = UserPrincipal.FindByIdentity(principalContext, Username);
I receive the error message:
There is no such object on the server.
here's a screenshot of my ActiveDirectory setup:
I've also tried using the following Container:
const string Container = "OU=Users,DC=SLO1,DC=Foo,DC=Bar,DC=biz";
this was equally unsuccessful.
How can I specify my container while accessing the 'Users' container? I'm trying to do this as an initial, simple setup before introducing a lookup with more complicated requirements. So, I'd rather not settle for the simple solution because I am going to have to troubleshoot this anyway, I believe.
LDAP://
protion in the string above shouldn't it be something likeLDAP://OU=Users,DC=SLO1,DC=Foo,DC=Bar,DC=biz
– Iago