I tried to use SQL queries to get active users from ActiveDirectory, using SQL Dialect.
However, documentation about it seems incomplete to me.
For example, how can I get only active users? (Flag that indicates that user is active is in second bit of userAccountControl field) But there is no bitwise operations nor any arithmetics in this dialect to get it.
Maybe I can somehow incorporate LDAP dialect into my SQL query, but I don’t see how…
I tried to use arithmetics and bitwise ops to retrieve that annoying bit, but nothing helped really.
Like this:
SELECT objectGUID, SAMAccountName, sn, mail, givenName, userAccountControl, company, department, memberOf
FROM 'LDAP://DC=my,DC=company'
WHERE objectClass = 'user' AND givenName = '*' AND userAccountControl % 4 < 2
Or
SELECT objectGUID, SAMAccountName, sn, mail, givenName, userAccountControl, company, department, memberOf
FROM 'LDAP://DC=my,DC=company'
WHERE objectClass = 'user' AND givenName = '*' AND userAccountControl & 2 = 0
Both variants had invalid syntax
Also I tried to find information in Internet, but still nothing
MSBear007 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.