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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Active Directory/MS Access VBA Issue

Status
Not open for further replies.

blanic

Programmer
Nov 10, 2001
1
US
My question is how do I fix the following issue:
All of the fields i have no issue with getting the information other than the "ACCOUNTEXPIRES" field. It is because it does not convert correctly or i have a bad setting. The following URL is something i tried, even modifiying with my limited ability but could not get it to work. If there is a way to take what is in that link to convert that field to the correct date (ACCOUNTEXPIRES) that is what I am trying to do. The other fields work as intended, please do not let the other code throw you it all works. I hope that better helps to what i am doing. Like i said the other fields work with no issues, it is the one field that is causing me this problem. Thanks again.
strOU1=LDAP://OU=TEST,DC=Test,DC=TEST,DC=TEST,DC=TEST
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("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.Properties("Chase referrals") = ADS_CHASE_REFERRALS_EXTERNAL
objCommand.CommandText = "SELECT givenName, sn, name, department, title, sAMAccountName, accountExpires, userAccountControl FROM '" & strOU1 & "' WHERE objectCategory='user' ORDER BY sAMAccountName"
Set objRecordset = objCommand.Execute
While Not objRecordset.EOF
Set strName = objRecordset.Fields("Name")
strName = Replace(strName, "'", "''")
Set strDept = objRecordset.Fields("department")
Set stradname = objRecordset.Fields("sAMAccountName")
Set strExp = objRecordset.Fields("accountExpires").Value
'Set strExp = objRecordset.Fields("accountExpires") 'I have tried this as well in place of the above

CurrentDb.Execute "Insert Into Test (Tname,adname,dept,exp) Values ( '" & strName & "', '" & stradname & "', '" & strDept & "', '" & strExp & "')", dbFailOnError
objRecordset.MoveNext
Wend
 
How did you define your variables?
[tt]
Dim strName As ???
Dim strDept As ???
Dim stradname As ???
Dim strExp As ???
[/tt]

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top