Server is unwilling to process request

Server is unwilling to process request

Post by wk6pac » Sat, 09 Apr 2005 07:07:27


Hi,

I'm trying to get Create users in AD using VB.Net. Can someone shed some
light on what that error is?
Error: "The server is unwilling to process the request."

Here is my code.

cnstr = CPerson.lastname + "\, " + CPerson.Firstname

displayname = CPerson.lastname + ", " + CPerson.Firstname

objParent = New DirectoryEntry("LDAP://OU=gvus,OU=gvsd,DC=sd61,DC=bc,DC=ca",
_

authname, _

authpwd, _

AuthenticationTypes.Secure)

objChild = objParent.Children.Add("cn=" + cnstr, "user")

Try

'set the default properties for a user account

objChild.Properties("sAMAccountName").Add(userid)

objChild.Properties("userAccountControl").Add(512)

objChild.Properties("userPrincipalName").Add(UPN)

objChild.Properties("givenname").Add(firstname)

objChild.Properties("sn").Add(CPerson.lastname)

objChild.Properties("displayname").Add(displayname)

objChild.Properties("title").Add(CPerson.title)

objChild.Properties("employeeID").Add(CPerson.EmpNo)

objChild.Properties("department").Add(CPerson.dept)

objChild.Properties("company").Add(CPerson.Category)

objChild.Properties("wWWHomePage").Add(CPerson.status)

objChild.CommitChanges()

Catch er As Exception

errorlog(CPerson, er.Message, "Create Account In Sub:")

End Try

thanks,
Will
 
 
 

Server is unwilling to process request

Post by MVP - AD » Sat, 09 Apr 2005 07:23:11

Do you have a domain password policy in place?

If so, you need to create the user with userAccountControl set to disabled,
then set a password and then enable the account. It is the 3 steps. AD
won't let you enable an account with no password if your password policy
doesn't allow null passwords.

Joe K.

 
 
 

Server is unwilling to process request

Post by wk6pac » Sat, 09 Apr 2005 07:52:38

Hi Joe,

how do I disable that property? What is the value to disable it? We do
have domain password policy.

thanks,
Will
"Joe Kaplan (MVP - ADSI)" < XXXX@XXXXX.COM > wrote

disabled,


some
 
 
 

Server is unwilling to process request

Post by MVP - AD » Sat, 09 Apr 2005 10:32:00

Check out the documentation in the ADSI SDK on MSDN for ADS_USER_FLAG_ENUM.
Essentially, you need to set the disabled bit as well as the normal account
bit.

ADS_UF_NORMAL_ACCOUNT Or ADS_UF_ACCOUNTDISABLE = 512 Or 2 = 514

Thus set userAccountControl to 514. Then set password. Then set back to
512.

Joe K.