Creating a User object in AD

P

Philip Carnstam

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
 
W

Willy Denoyette [MVP]

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.
 
P

Philip Carnstam

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 said:
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 said:
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
 
M

Marc Scheuner [MVP ADSI]

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
 

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

Top