Jump to content

Problem in reading attributes from AD/ED


Recommended Posts

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 & Password

Below 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.EOF

Set objUser = GetObject(objRS.Fields("adspath").Value)

objUser.GetInfo

objUser.Get("uid")

strEx = objUser.Get("cn")

MsgBox strEx

strADSPath = objRS.Fields("adspath").Value

MsgBox strADSPath

objRS.MoveNext

Wend

directoryConn.close

Dim directoryConn1

Dim 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.EOF

Set objUser1 = GetObject(objRS1.Fields("adspath").Value)

objUser1.GetInfo

strEx1 = objUser1.Get("manager")

MsgBox strEx1

strEx = objUser1.Get("passwordexpirationtime")

MsgBox strEx

objRS.MoveNext

Wend

'

'objRS1.close

'directoryConn1.Close

Link to comment
Share on other sites

  • 2 weeks later...

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...