goodami Posted July 6, 2006 Share Posted July 6, 2006 HI ,I have to find an operational attribute from Active Directoyry using VBsCript.I do not know how to get that since:1)It needs authentication form user.So how to connect to AD using Username & PasswordBelow is the code:strBase = ";" strFilter = "(uid=test amit);" strAttrs = "adspath;"strScope = "subtree" Set directoryConn = CreateObject("ADODB.Connection")directoryConn.Provider = "ADsDSOObject"directoryConn.Open "Active Directory Provider"Set objRS = directoryConn.Execute(strBase & strFilter & strAttrs & strScope)Dim objUser While Not objRS.EOFSet objUser = GetObject(objRS.Fields("adspath").Value)objUser.GetInfoobjUser.Get("uid")strEx = objUser.Get("cn")MsgBox strExstrADSPath = objRS.Fields("adspath").Value MsgBox strADSPath objRS.MoveNextWenddirectoryConn.close Dim directoryConn1Dim objRS1 Dim dn dn = "uid=" & objUser.Get("uid") & ",ou=people,dc=abc,dc=com"MsgBox dn''Set dso = GetObject("LDAP:")'Set tmpUser = dso.OpenDSObject( strADSPath,"test amit","1234",1)'tmpUser.GetInfoEx Array("passwordexpirationtime"), 0'MsgBox tmpUser.Get("passwordexpirationtime")Set directoryConn1 = CreateObject("ADODB.Connection")directoryConn1.Provider = "ADsDSOObject"directoryConn1.Properties("User ID") = "test amit"directoryConn1.Properties("Password") = "1234"directoryConn1.Properties("Encrypt Password") = "FALSE"directoryConn1.Open "Active Directory Provider"strAttrs = "passwordexpirationtime;"strScope = "subtree" Set objRS1 = directoryConn1.Execute(strBase & strFilter & strAttrs & strScope) While Not objRS1.EOFSet objUser1 = GetObject(objRS1.Fields("adspath").Value)objUser1.GetInfostrEx1 = objUser1.Get("manager")MsgBox strEx1 strEx = objUser1.Get("passwordexpirationtime")MsgBox strEx objRS.MoveNextWend' 'objRS1.close'directoryConn1.Close Link to comment Share on other sites More sharing options...
Zartach Posted July 18, 2006 Share Posted July 18, 2006 Running a sccript agains the AD should not require a username or pasword, are you running the script from a pc thats a member of the domain ? can you try running it on a DC ?I have numerous scripts running collecting info and sometimes adding info to the AD and had never had problems with having to autenticate. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now