I am trying to set up a handler for expiring accounts in AD to send notifications and to flag accounts to decommission once expired.
I was originally using the AD functions built in for querying the users, but it is exceedingly slow to perform a list object path, then walk through each to perform an additional get object dataset account to populate variables, then weed through each of those to identify the ones I need. It took 9 seconds to process a single user this way.
As an alternative we are looking to utilize the SQL ADsDSOObject interface instead so it's a single query and it populates a dataset with all of the responses with the properties we care about. The problem is the accountExpires field.
When executing this code:
<AMDATABASE ACTIVITY="sql_query" CONNECTIONTYPE="connection_string" CONNECTION="Provider=ADsDSOObject;Encrypt Password=False;Integrated Security=SSPI;Mode=Read;Bind Flags=0;ADSI Flag=-2147483648" RESULTDATASET="UserList">SELECT
cn,
SAMAccountName,
mail,
employeeType,
manager,
accountExpires,
department,
l,
o,
orgName,
company
FROM
'LDAP://OU=Contractor,OU=Accounts,DC=MYCOMPANY,DC=com'
Where
objectCategory='user' AND
objectClass='organizationalPerson' AND
accountExpires>=%Yesterday% AND
accountExpires<=%Today%</AMDATABASE>
I get the response back from it, however, UserList.accountExpires shows as a blank value in the Variables view. When I attempt to view it through a msgbox I receive the error "[Main](Step 24) Syntax error: wrong type". If I display the VarType on it, I get a 9, which is a vbObject!
Has anyone attempted to view accountExpires through a SQL call? Does anyone know the properties that I need to access to view the actual value?
This also occurs when executed in this manner:
<AMDATABASE ACTIVITY="sql_query" CONNECTIONTYPE="connection_string" CONNECTION="Provider=ADsDSOObject;Encrypt Password=False;Integrated Security=SSPI;Mode=Read;Bind Flags=0;ADSI Flag=-2147483648" RESULTDATASET="UserList" AM_ENABLED="NO"><LDAP://OU=Contractor,OU=Accounts,DC=MYCOMPANY,DC=com>;(&(objectCategory=user)(objectClass=organizationalPerson)(accountExpires>=%Yesterday%)(accountExpires<=%Today%));cn,samaccountname,mail,employeetype,manager,accountexpires,department,l,o,orgName,company;onelevel</AMDATABASE>
This is on Automate 11.0.6.11 Standard on Windows Server 2016.