UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Active Directory/VBA Issue    
 
   
blanic
post Apr 27 2015, 09:04 AM
Post#1



Posts: 1
Joined: 22-April 15



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. http://www.rlmueller.net/Integer8Attributes.htm
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


It fails on strEXP and never gets to execute the insert into.
Go to the top of the page
 
dmhzx
post Apr 27 2015, 09:35 AM
Post#2



Posts: 7,033
Joined: 22-December 10
From: England


I'm only guessing here, but I don't see any DIMs in your code.
Could it be that the variable is a string, and you're trying to set it to a date?

If so you'll need to change the values string as well.
Go to the top of the page
 
JVanKirk
post Jul 5 2016, 03:17 PM
Post#3


UtterAccess VIP
Posts: 4,209
Joined: 4-March 04
From: Clarksville, TN


I know this is an old post, but if it never got resolved, could it be that the # signs are missing from around the date:

CurrentDb.Execute "Insert Into Test (Tname,adname,dept,exp) Values ( '" & strName & "', '" & stradname & "', '" & strDept & "', '" & strExp & "')", dbFailOnError

Maybe should be:

CurrentDb.Execute "Insert Into Test (Tname,adname,dept,exp) Values ( '" & strName & "', '" & stradname & "', '" & strDept & "', #" & strExp & "#)", dbFailOnError
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    16th December 2017 - 09:12 PM