I am trying to create an organizational unit for Active Directory using the code below.
strPath = "OU=TestOU,DC=Internal,DC=Com"
DirectoryEntry objOU;
objOU = ADentry.Children.Add(strPath, "OrganizationalUnit");
objOU.CommitChanges();
The problem is that strPath contains the full path "OU = TestOU, DC = Internal, DC = net", so using .Children.Add makes the path ldap "OU = TestOU, DC = Internal, DC = net, DC = Internal, DC = net ', which leads to an error, because, apparently, the domain does not exist.
My question is: can I create an OU using strPathwithout .Children.Add?
I am not familiar with AD, and this is what I inherited from the guy in front of me.
James may
source
share