I need to find out disabled users from ldap
Asked Answered
F

1

6

I am trying to find out whether a user is disabled in ldap using ldapsearch utility but I have been unsuccessful so far. This is what i have got so far

ldapsearch -h hostname -D 'Service Account' -b 'basedn' sAMAccountName='disabled user' -w 'password'
# extended LDIF
#
# LDAPv3
# base <basedn> with scope subtree
# filter: sAMAccountName=disabled user
# requesting: ALL
#

# search result
search: 2
result: 0 Success

# numResponses: 1

I have even tried with -LLL nsaccountlock it give me nothing. Its the same with a random string for user as well. I need to find out that the user that I am specifying whether its an active or disabled user or not a user at all. Am I doing something wrong? is there another utility I can use to determine if the user is disabled

Frontage answered 4/10, 2017 at 22:20 Comment(2)
You need to specify the attribute that contains the lockout information, whatever it is. It isn't returned by default.Irade
I tried -LLL fcAccountStatus but it doesnt work eitherFrontage
M
4

You can use this filter:

(&(objectCategory=person)(objectClass=user)(userAccountControl:1.2.840.113556.1.4.803:=2))

To find all users with the User-Account-Control value of 0x00000002

Mylonite answered 5/10, 2017 at 8:1 Comment(6)
I tried ldapsearch -h hostname -D 'Service Account' -b 'basedn' sAMAccountName='disabled user' -w 'password' (&(objectCategory=person)(objectClass=user)(userAccountControl:1.2.840.113556.1.4.803:=2)) but it gave me an error -bash: syntax error near unexpected token `('Frontage
That is something to do with bash escaping. Try using quotes (or double quotes) something like ldapsearch -h hostname -D 'Service Account' -b 'basedn' sAMAccountName='disabled user' -w 'password' '(&(objectCategory=person)(objectClass=user)(userAccountContr‌​ol:1.2.840.113556.1.‌​4.803:=2))'Mylonite
ok single quotes did work, Thank You, but all I get is this information # extended LDIF # # LDAPv3 # base <ou=Employees,ou=Accounts,ou=Fidelis,DC=ads,DC=fideliscare,DC=org> with scope subtree # filter: sAMAccountName=disabled user # requesting: (&(objectCategory=person)(objectClass=user)(userAccountCont‌​r‌​ol:1.2.840.113556‌​.1.‌​4.803:=2)) # # search result search: 2 result: 0 SuccessFrontage
I tried the userAccountControl value and it returns some disabled accounts, but one specific is not returned. I tried to find any differences through the Windows AD Tools, but was not able to find any. Strange.Speculation
It is a disabled account or a "locked out" account? Do you have permissions to read the account?Mylonite
If anyone is confused like me, that horrible long number 1.2.840.113556.1.4.803 is the LDAP Rule OID for "Bitwise AND" - see learn.microsoft.com/en-us/windows/win32/adsi/…Francoise

© 2022 - 2024 — McMap. All rights reserved.