I’m writing an application that will add users to Active Directory. I’m trying to use this code to connect to the “Users” shared folder in AD
LDAP://celtestdomdc1.celtestdom.local/CN=Users,DC=celtestdom,DC=local
However it adds the user in with the shared folders, instead of within the “Users” shared folder. Shouldn’t CN=Users mean it will add it to the “Users” folder?
Thanks
If you’re creating a user, you need to
Just by setting the LDAP path, you are not defining where the user will go!
Try something like this (C# sample – should be trivial to convert to VB.NET):
Or if you’re using .NET 3.5 or newer, you could also use the new
System.DirectoryServices.AccountManagementnamespace that makes lots of things easier.Then the code looks a bit simpler:
Check out more about the
System.DirectoryServices.AccountManagement(S.DS.AM) namespace here: