Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script to check "user can not change password"

Status
Not open for further replies.

boein

Technical User
Jul 17, 2003
84
BE
Hi,

I need a script to check the status of this parameter in AD, anybody idea's? It should fit in this code

Dim objconnection, objcommand, objrecordset, objuser, objproperty
Set objconnection = CreateObject("ADODB.Connection")
Set objcommand = CreateObject("ADODB.Command")
objconnection.Provider = "ADsDSOObject"
objconnection.Open "Active Directory Provider"
Set objcommand.ActiveConnection = objconnection
objcommand.Properties("Page Size") = 1000
objcommand.Properties("Timeout") = 30
objcommand.Properties("Searchscope") = 2
objcommand.Properties("Cache Results") = False

On Error Resume Next
objcommand.CommandText = _
"Select * from 'LDAP://dc=indaver,dc=int'" & " where samaccountname='" & wscript.arguments(0) & "'"
Set objrecordset = objcommand.Execute
objrecordset.MoveFirst
Set objuser = GetObject(objrecordset.Fields("ADsPath").Value)

<CHECK IF USER CANNOT CHANGE PASSWORD IS ENABLED OR NOT>

objproperty = Null
 
Thanks,

I found a way to do it, but I still have another problem. Is there a way to pass exit codes coming from vbs to vb6.
My main program (vb6) calls a vbs-script executed by Psexec this script should give an exit code to the main program. Is this possible?

ShellandWait "psexec \\" & computername & " -u userid -p password -e cscript.exe //B //NoLogo ""c:\pwreset.vbs"" " & Trim(userid.Text) & " " & Trim(newpw1.Text)

in the vbs-script (see above) there should be a line
If error
wscript.Quit(1)
else
wscript.Quit(0)
end if

but this doesn't work. Basicaly this is what I'm trying to do. A normal user must be able to check is he can change his pasword or not, if not the main program should display an error. With Psexec I run the password check with admin-rights via the pwreset.vbs this script should return an exit code. I could display the message in the vbs-script but then a user can interact with the program and I don't want that.

Any ideas?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top