Tech Support > Operating Systems > Windows 2003 > Adding Users
Adding Users
Posted by Loke Kit Kai on December 16th, 2003


Hi,

I need help again... Please help me... I have no idea what is the error...

I followed the example on
http://msdn.microsoft.com/library/de...asp?frame=true.
Extracted from MSDN:
DirectoryEntry ent = new DirectoryEntry();
DirectoryEntry ou = ent.Children.Find("OU=Consulting");

// Use the Add method to add a user in an organizational unit.
DirectoryEntry usr = ou.Children.Add("CN=New User","user");
// Set the samAccountName, then commit changes to the directory.
usr.Properties["samAccountName"].Value = "newuser";
usr.CommitChanges();

But i just need to add user to the default users container, so i tot can
take out the find line and below is my code

AdRootDSE = new System.DirectoryServices.DirectoryEntry("LDAP://" +
oSettings.getValue(HP.SharePoint.EmployeePortal.Gl obalSettings.AD_DOMAIN));
AdRoot = new System.DirectoryServices.DirectoryEntry("LDAP://" +
(string)AdRootDSE.Properties["defaultNamingContext"].Value);
System.DirectoryServices.DirectoryEntry path =
AdRoot.Children.Find("Container=Users");
System.DirectoryServices.DirectoryEntry newUser = path.Children.Add("CN=" +
this.txtAccountName.Text, "User");

it keeps giving me 80005000 error, with not description to help me debug...
Below is the errors
System.DirectorySertices.DirectoryEntry.Bind(Boole an throwIfFail) +513
System.DirectoryServices.DirectoryEntry.Bind() +10
System.DirectoryServices.DirectoryEntry.get_IsCont ainer() +10
System.DirectoryServices.DirectoryEntries.CheckIsC ontainer() + 14
System.DirectoryServices.DirectoryEntries.Find(Str ing name, String
schemaClassName) +14
System.DirectoryServices.DirectoryEntries.Find(Str ing name) + 7
..
..
..
'
I've check the trace report at the end of the asp.net page and I'm login as
administrator.

Anyone knows what is happening? Appreciated it a lot.
BTW, what is the +xx on the right of the function call means?

Sincerely,
Kit Kai



Posted by Wolfgang Kais on December 16th, 2003


Hello Kit Kai.

"Loke Kit Kai" wrote:

Try to find "CN=Users" (not "Container=Users").

--
Regards,
Wolfgang



Posted by Loke Kit Kai on December 16th, 2003


Thanks Wolfgang and Max,
I'll try that tomolo first thing in the office.

Really appreciated your help
Kit Kai


"Wolfgang Kais" <w.kais@removethisgmx.de> wrote in message
news:eM3a2b%23wDHA.1736@TK2MSFTNGP09.phx.gbl...



Similar Posts