cannot create new object in ActiveDirectory

Posted by Humanier on Stack Overflow See other posts from Stack Overflow or by Humanier
Published on 2010-05-22T11:43:41Z Indexed on 2010/05/22 11:50 UTC
Read the original article Hit count: 188

Filed under:

Hi.

I'm trying to add new object to existing organisational unit in Active Directory. Following code is used to do this.

It runs without errors. But new object is not created after this. Please advise what I'm doing wrong here.

using System.DirectoryServices;
using System.DirectoryServices.ActiveDirectory;

namespace TestAdObjectCreation
{
    class Program
    {
        static void Main(string[] args)
        {
            DirectoryEntry root = new DirectoryEntry("LDAP://servername/OU=Services,OU=PCX,DC=q2q,DC=xenyq,DC=com", "Administrator", "pass");
            DirectoryEntry newItem = root.Children.Add("test_node", "valid_schema_class_name");
            root.CommitChanges();
            root.Close();
            root.Dispose();
        }
    }
}

© Stack Overflow or respective owner

Related posts about active-directory