问题
I'm now at a loss; I've tried this script several different ways but keep getting an error that says There is no such object on the server at character 20,2
.
This line reads
Set objOU = GetObject("LDAP://ou=users,dc=asp,dc=rippe,dc=com")
I get a different error when I change OU
to CN
next to users.
The end result desired is to have all of the variables taken from an HTML form and then the script will run to create a new user on our domain.
I haven't even got to the adding the user to groups yet because I can't get past this road block.
Dim strID,StrFName,strLName,strFirm,strPwd,strServer,strLMS,strSql,strLMSV
strID = zademo
strFName = Demo
strLName = Tester
strFirm = Demo
strPwd = za1234
strServer = rkasp01
strLMS = y
strSql = y
strLMSV = y
strDisplay = strLName & ", " & strFName
'Create Citrix User Account
If strSql = y OR strLMSV = y Then
Set objOU = GetObject("LDAP://ou=Users,dc=asp,dc=rippe,dc=com")
Set objUser = objOU.Create("User", "cn=" & strDisplay)
objUser.Put "sAMAccountName", strID
objUser.Put "Description", strFirm
objUser.Put "givenName", strFName
objUser.Put "sn", strLName
objUser.Put "displayName", strDisplay
objUser.Put "homedirectory", "\\rkpdc\" & strFirm & "\" & strID
objUser.Put "scriptpath", strFirm & ".bat"
objUser.SetInfo
End If
objUser.SetPassword strPwd
objUser.Put "PasswordExpired", CLng(1)
objUser.AccountDisabled = FALSE
objUser.SetInfo
回答1:
Set objOU = GetObject("LDAP://ou=Users,dc=asp,dc=rippe,dc=com")
Usually "Users" is a container, not an OU.
Try:
Set objOU = GetObject("LDAP://CN=Users,dc=asp,dc=rippe,dc=com")
回答2:
Have you tried and replace example.com with the actual domain.
GetObject("LDAP://example.com/OU=Users,DC=asp,DC=rippe,DC=com")
回答3:
Option Explicit
Dim strUserName
Dim objRootLDAP
Dim objContainer
Dim objNewUser
strUserName = "MorganTestUser"
Set objRootLDAP = GetObject("LDAP://rootDSE")
' You can give your own OU like LDAP://OU=TestOU instead of LDAP://CN=Users
Set objContainer = GetObject("LDAP://CN=Users," & _
objRootLDAP.Get("defaultNamingContext"))
Set objNewUser = objContainer.Create("User", "cn=" & strUserName)
objNewUser.Put "sAMAccountName", strUserName
objNewUser.Put "givenName", "Morgan"
objNewUser.Put "sn", "TestUser"
objNewUser.Put "displayName", "Morgan TestUser"
objNewUser.Put "Description", "AD User created by VB Script"
objNewUser.SetInfo
objNewUser.SetPassword "MyPassword123"
objNewUser.Put "PasswordExpired", CLng(1)
objNewUser.AccountDisabled = FALSE
MsgBox ("New Active Directory User created successfully by using VB Script...")
WScript.Quit
来源:https://stackoverflow.com/questions/14074505/error-while-attempting-to-add-a-user-to-active-directory