Quote:
Originally posted by jlot6
Need a little more information then that?
|
I want to create a new User in my Active Directory
My code is
<%
%
Dim userName
Dim userPass
Dim userAcount
strName=request.form("text1")
strInitialPassword= request.form("text2")
strSAMAccountName= request.form("text3")
Dim objRootDSE
Dim objUsers
Dim objNewUser
On Error Resume Next
' Bind to the rootDSE object.
Set objRootDSE = GetObject("LDAP://rootDSE")
If (Err.Number <> 0) Then
response.write "Error1 "
End If
' Bind to the Users folder in the domain.
Set objUsers = GetObject("LDAP://CN=Users," & objRootDSE.Get("defaultNamingContext"))
If (Err.Number <> 0) Then
response.write "Error2 "
End If
' Create the user object.
Set objNewUser = objUsers.Create("user", "CN=" + strName)
If (Err.Number <> 0) Then
response.write "Error3 "
End If
' Set the sAMAccountName property.
objNewUser.Put "sAMAccountName", strSAMAccountName
If (Err.Number <> 0) Then
response.write "Error4 "
End If
' Commit the new user.
objNewUser.SetInfo
If (Err.Number <> 0) Then
response.write "Error5 "
End If
' Set the initial password. This must be done after
' SetInfo is called because the user object must
' already exist on the server.
objNewUser.SetPassword strInitialPassword
If (Err.Number <> 0) Then
response.write "Error6 "
End If
' Set the pwdLastSet property to zero, which forces the
' user to change the password at next log on.
objNewUser.Put "pwdLastSet", 0
If (Err.Number <> 0) Then
response.write "Error7 "
End If
userActCtrl = objNewUser.Get("userAccountControl")
userActCtrl = userActCtrl And Not (ADS_UF_ACCOUNTDISABLE + ADS_UF_PASSWD_NOTREQD + ADS_UF_DONT_EXPIRE_PASSWD)
objNewUser.Put "userAccountControl", userActCtrl
If (Err.Number <> 0) Then
response.write "Error8 "
End If
objNewUser.SetInfo
%>
It's print to me "Error5" What's wrong??? Untill "Error5" no problems.
How to fix it???