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