469,625 Members | 1,155 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,625 developers. It's quick & easy.

Creating a User object in AD

Hi,

Can someone lead me through creating a user object in AD.

I have tried creating one through LDAP and ADSI (WinNT://) but nothing
happens.

DirectoryEntry DE = new DirectoryObject("CN=users,DC=ADomain,DC=com");
DE.Children.Add("Philip", "user");
DE.CommitChanges();

This script does absolutely nothing. Why?
Thanks,
Philip


Nov 16 '05 #1
3 1828
Your DirectoryObject should at least contain a correct LDAP ADsPath;
LDAP://HostName[:PortNumber][/DistinguishedName]

In your case
DirectoryEntry DE = new
DirectoryObject(LDAP://serverName/CN=users,DC=ADomain,DC=com);
Where serverName is the name of the AD server host or the domain name.

Willy.

"Philip Carnstam" <ph****@carnstam.net> wrote in message
news:eh**************@TK2MSFTNGP12.phx.gbl...
Hi,

Can someone lead me through creating a user object in AD.

I have tried creating one through LDAP and ADSI (WinNT://) but nothing
happens.

DirectoryEntry DE = new DirectoryObject("CN=users,DC=ADomain,DC=com");
DE.Children.Add("Philip", "user");
DE.CommitChanges();

This script does absolutely nothing. Why?
Thanks,
Philip

Nov 16 '05 #2
The address is not the problem, I know the one entered here was not fully
correct. I can access any object, I just can't create new ones.
"Willy Denoyette [MVP]" <wi*************@pandora.be> wrote in message
news:eg*************@TK2MSFTNGP12.phx.gbl...
Your DirectoryObject should at least contain a correct LDAP ADsPath;
LDAP://HostName[:PortNumber][/DistinguishedName]

In your case
DirectoryEntry DE = new
DirectoryObject(LDAP://serverName/CN=users,DC=ADomain,DC=com);
Where serverName is the name of the AD server host or the domain name.

Willy.

"Philip Carnstam" <ph****@carnstam.net> wrote in message
news:eh**************@TK2MSFTNGP12.phx.gbl...
Hi,

Can someone lead me through creating a user object in AD.

I have tried creating one through LDAP and ADSI (WinNT://) but nothing
happens.

DirectoryEntry DE = new DirectoryObject("CN=users,DC=ADomain,DC=com");
DE.Children.Add("Philip", "user");
DE.CommitChanges();

This script does absolutely nothing. Why?
Thanks,
Philip


Nov 16 '05 #3
>DirectoryEntry DE = new DirectoryObject("CN=users,DC=ADomain,DC=com");

This is an invalid LDAP bind string..... it should be something like
this:

DirectoryEntry DE = new
DirectoryObject("LDAP://CN=users,DC=ADomain,DC=com");
DE.Children.Add("Philip", "user");
This is invalid again - you'll need to specify the user name in LDAP
style, e.g. including the cn= prefix:

DE.Children.Add("cn=Philip", "user");
DE.CommitChanges();


And before that, you will need to set at least all the mandatory
properites of the user object, which includes the samAccountName,
which has to be unique in the whole domain:

DE.Properties["sAMAccountName"].Value = "philipp";

THEN

DE.CommitChanges();

Now you should see your new user object in AD.

Marc
================================================== ==============
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch
Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Altramagnus | last post: by
15 posts views Thread by Carlos Lozano | last post: by
2 posts views Thread by DaWoE | last post: by
12 posts views Thread by Mats Lycken | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.