Adding OU

G

Guest

Hi
How can we add OU to a directory? TIA details.....

I have tried using the following code but getting exception error

Exception: The specified directory service attribute or value does not
exist.

-------------
str_path = "DC=mydomain,DC=com";
newOUName = "OU=anotherOU";
DirectoryEntry myDir = new DirectoryEntry(str_path, uName,
uPwd);
DirectoryEntry newOU = myDir.Children.Add(newOUName,
"Organizational-Unit");
newOU.CommitChanges();
 
G

Guest

Hi
I get a bit progress on this, now I am getting naming violation with the
following code

newOUName=DN="OU=anotherOU,DC=mydomain, DC=com";
DirectoryEntry myDir = new DirectoryEntry(str_path, uName,
uPwd);
DirectoryEntry newOU = myDir.Children.Add(newOUName,
"organizationalUnit");
newOU.CommitChanges();

Any idea, please?
TIA
 
J

Joe Kaplan \(MVP - ADSI\)

Right, it is an RDN value, or relative distinguished name. Sounds like you
got it now.

Joe K.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,811
Messages
2,569,693
Members
45,477
Latest member
IsidroSeli

Latest Threads

Top