I'm struggling to create an OU 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 strPath contains the full path 'OU=TestOU,DC=Internal,DC=net' so using .Children.Add is making the ldap path 'OU=TestOU,DC=Internal,DC=net,DC=Internal,DC=net' which results in an error as the domain obviously doesn't exist.
My question is can I create an OU using strPath
without .Children.Add
?
I'm not familiar with AD and this is something I inherited from the guy before me.