Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Software > ADSI General > Error/Failure a...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 5344 of 5423
Post > Topic >>

Error/Failure adding user to AD

by =?Utf-8?B?dHJpY2t5?= <tricky@[EMAIL PROTECTED] > Jul 29, 2008 at 04:52 AM

I am having trouble adding a user to AD with the following code:

public static DirectoryEntry  CreateNewUser(string samAccountName)
{
	//set the LDAP qualification so that the user will be created under the
Users
	//container.
	// GetLDAPDomain will read in the ADServer value from the web.config and 
will return it
	// as an LDAP path eg DC=SVR1, DC=HEADOFFICE, DC=NET.
	string LDAPDomain ="/CN=Users," + GetLDAPDomain() ;
	DirectoryEntry oDE= GetDirectoryObject(LDAPDomain);
	DirectoryEntry oDEC=oDE.Children.Add("CN=Testuser","User");
	oDE.Close();
	return oDEC;

}


private static DirectoryEntry GetDirectoryObject()
{
//please note ADUser & Pass are Domain Administrator details 
currently	DirectoryEntry oDE;
	oDE = new 
DirectoryEntry(ADPath,ADUser,ADPassword,AuthenticationTypes.Secure);
	return oDE;
}

GetDirectoryObject appears OK as i use it to perform a directorysearch
which 
works well. When running the above code the following line throws the 
following exception:

line in question:
DirectoryEntry oDEC=oDE.Children.Add("CN=Testuser","User");

Exception info:
[COMException (0x80005000): Unknown error (0x80005000)]
   System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
   System.DirectoryServices.DirectoryEntry.Bind()
   System.DirectoryServices.DirectoryEntry.get_IsContainer()
   System.DirectoryServices.DirectoryEntries.CheckIsContainer()
   System.DirectoryServices.DirectoryEntries.Add(String name, String 
schemaClassName)

Dev/Testing Environment is as follows:
Single Machine IIS Server AND Domain Controller
Windows 2003 STD SPK2
VIS Studio 2003
..NET 1.1
Application using Basic Authentication (this is a must)
App Pool Identity=network service

I have tried running the code impersonating the administrator details.

Any help is much appreciated
 




 3 Posts in Topic:
Error/Failure adding user to AD
=?Utf-8?B?dHJpY2t5?= <  2008-07-29 04:52:01 
Re: Error/Failure adding user to AD
"Joe Kaplan" &l  2008-07-29 09:13:20 
Re: Error/Failure adding user to AD
=?Utf-8?B?dHJpY2t5?= <  2008-07-29 18:46:00 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue Dec 2 7:18:07 CST 2008.