C
Chai
Hi Michael Holzemer and others,
I create a script (follow TechNet guide) that will read a
list a users and other fields in the MsSQL table then
check the Active Directory to see whether if the user
exist. If no, then it will create the user and insert the
value for the fields (which I create few attributes - AD
Schema Extending).
When I run the script below, i receive an error
message "Server unwilling to ptocess the request". Can
anyone help?
Thanks.
===========================================================
Sub CheckUser
Dim oUser, oDomain, found
found = 0
Set oDomain = GetObject("LDAP://dc=mycompany,dc=com")
oDomain.Filter = Array("user")
For Each oUser In oDomain
If LCase(oUser.Name) = LCase(sUserName) Then
found = 1
End If
Next
if found = 0 then
call CreateUser
end if
End Sub
'---------------------------------------------------------
Sub CreateUser
Dim oUser, oDomain
Set oDomain = GetObject(""LDAP://dc=mycompany,dc=com")
Set oUser = oDomain.Create("user", sUserName)
oUser.SetPassword "password"
ouser.FullName = fname
ouser.Description = fcourse
oUser.company = fintake
ouser.Intake = fintake
ouser.sessionjoint = fsessjoin
ouser.currentsession = fcurrsess
ouser.status = fstatus
ouser.withdrawday = fwdrdt
oUser.SetInfo
oUser.AccountDisabled = FALSE
WScript.Echo "Account created for", sUserName, "in",
sDomainName
End Sub
'---------------------------------------------------------
sub CallDatabase
Set adoDataConn = CreateObject("ADODB.Connection")
adoDataConn.Open "test"
strQuery = "SELECT * FROM table1;"
Set RS = adoDataConn.Execute(strQuery)
while not RS.eof
sUserName = rs.Fields("fregkey")
fname = rs.Fields("fname")
fcourse = rs.Fields("fcourse")
fintake = rs.Fields("fintake")
fsessjoin = rs.Fields("fsessjoin")
fcurrsess = rs.Fields("fcurrsess")
fstatus = rs.Fields("fstatus")
wdrdt = rs.Fields("fwdrdt")
Call QueryForUser
RS.MoveNext
wend
RS.Close
adoDataConn.Close
End Sub
'---------------------------------------------------------
Dim sUserName, sDomainName, fregkey, fname, fcourse,
fintake, fsessjoin, fcurrsess, fstatus,fwdrdt
call CallDatabase
I create a script (follow TechNet guide) that will read a
list a users and other fields in the MsSQL table then
check the Active Directory to see whether if the user
exist. If no, then it will create the user and insert the
value for the fields (which I create few attributes - AD
Schema Extending).
When I run the script below, i receive an error
message "Server unwilling to ptocess the request". Can
anyone help?
Thanks.
===========================================================
Sub CheckUser
Dim oUser, oDomain, found
found = 0
Set oDomain = GetObject("LDAP://dc=mycompany,dc=com")
oDomain.Filter = Array("user")
For Each oUser In oDomain
If LCase(oUser.Name) = LCase(sUserName) Then
found = 1
End If
Next
if found = 0 then
call CreateUser
end if
End Sub
'---------------------------------------------------------
Sub CreateUser
Dim oUser, oDomain
Set oDomain = GetObject(""LDAP://dc=mycompany,dc=com")
Set oUser = oDomain.Create("user", sUserName)
oUser.SetPassword "password"
ouser.FullName = fname
ouser.Description = fcourse
oUser.company = fintake
ouser.Intake = fintake
ouser.sessionjoint = fsessjoin
ouser.currentsession = fcurrsess
ouser.status = fstatus
ouser.withdrawday = fwdrdt
oUser.SetInfo
oUser.AccountDisabled = FALSE
WScript.Echo "Account created for", sUserName, "in",
sDomainName
End Sub
'---------------------------------------------------------
sub CallDatabase
Set adoDataConn = CreateObject("ADODB.Connection")
adoDataConn.Open "test"
strQuery = "SELECT * FROM table1;"
Set RS = adoDataConn.Execute(strQuery)
while not RS.eof
sUserName = rs.Fields("fregkey")
fname = rs.Fields("fname")
fcourse = rs.Fields("fcourse")
fintake = rs.Fields("fintake")
fsessjoin = rs.Fields("fsessjoin")
fcurrsess = rs.Fields("fcurrsess")
fstatus = rs.Fields("fstatus")
wdrdt = rs.Fields("fwdrdt")
Call QueryForUser
RS.MoveNext
wend
RS.Close
adoDataConn.Close
End Sub
'---------------------------------------------------------
Dim sUserName, sDomainName, fregkey, fname, fcourse,
fintake, fsessjoin, fcurrsess, fstatus,fwdrdt
call CallDatabase