Active Directory
-
Hi All; I am trying to create users in AD, by separating the surname and first name by comma with the code: string OrgUnit ="LDAP://OU=Test,DC=Dev,DC=net"; DirectoryEntry rootentry = new DirectoryEntry (OrgUnit,"UserName","admin",0); ActiveDs.IADsContainer con = (ActiveDs.IADsContainer) rootentry.NativeObject; ActiveDs.IADsUser objUser = (ActiveDs.IADsUser) con.Create ("user","cn=Test, User'"); objUser.SetInfo (); The error i got was : An invalid dn syntax has been specified; What am i doing wrong? Thanks;
-
Hi All; I am trying to create users in AD, by separating the surname and first name by comma with the code: string OrgUnit ="LDAP://OU=Test,DC=Dev,DC=net"; DirectoryEntry rootentry = new DirectoryEntry (OrgUnit,"UserName","admin",0); ActiveDs.IADsContainer con = (ActiveDs.IADsContainer) rootentry.NativeObject; ActiveDs.IADsUser objUser = (ActiveDs.IADsUser) con.Create ("user","cn=Test, User'"); objUser.SetInfo (); The error i got was : An invalid dn syntax has been specified; What am i doing wrong? Thanks;
I have not done any writing to AD myself, but i use these lines for reading:
System.DirectoryServices.DirectorySearcher mySearcher = new System.DirectoryServices.DirectorySearcher(directoryEntry); mySearcher.Filter = ("(objectClass=user)"); mySearcher.Sort = new SortOption("sn", System.DirectoryServices.SortDirection.Ascending);
Maybe you should user objectClass=user instead of just user. I'm not sure that is the sollution, but maybe i got you in the right direction