I need to query AD to determine if the user account is disabled.
Using a similar query used in answers here
SELECT *
FROM OPENQUERY(ADSI, 'SELECT sAMAccountName
FROM ''LDAP://DC=MyDC,DC=com,DC=uk''
WHERE objectCategory = ''Person''
AND objectClass = ''user'')
I believe that to determine if the account is disabled, I need to somehow use the userAccountControl field. I tried a few things, but they don't seem to work:
WHERE userAccountControl & 2 <> 0
source
share