karephre
asked on
run vbscript with alternate credentials
Hello I use a local script to query my active directory. On the part that deletes a user or computer object. i would like that to run on administrator credentials.
I know how to set it up if I was using VB to run on a remote system, but cant figur out how to get it to run on a local one. with out doing run as admin.
Below is the part of my code I want to run under admin.
thanks experts
I know how to set it up if I was using VB to run on a remote system, but cant figur out how to get it to run on a local one. with out doing run as admin.
Below is the part of my code I want to run under admin.
thanks experts
Public Function delMac(macName,macLoc)
On Error Resume Next
Set objOU = GetObject("LDAP://"& macLoc &"")
objOU.Delete "user", "cn="& macName &""
End Function
Public Function delCom(ComDn)
On Error Resume Next
set objComputer = GetObject("LDAP://" & ComDn & "")
objComputer.DeleteObject (0)
End Function
ASKER
Below is what I added to my code, and im getting object already exists. After the computers are deleted I create them again.
Public Function delMac(macName,macLoc)
On Error Resume Next
Const ADS_SECURE_AUTHENTICATION = 1
Set objOU = GetObject("LDAP://"& macLoc ,"d.hot", "THer$#2",ADS_SECURE_AUTHENTICATION)
objOU.Delete "user", "cn="& macName &""
End Function
Public Function delCom(ComDn)
On Error Resume Next
Const ADS_SECURE_AUTHENTICATION = 1
set objComputer = GetObject("LDAP://" & ComDn ,"d.hot", "THer$#2",ADS_SECURE_AUTHENTICATION)
objComputer.DeleteObject (0)
End Function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Work like a champ ... Thanks RobSampson
No problem. Thanks for the grade.
Rob.
Rob.
Open in new window
Regards,
Rob.