Jack_Frost
Jack_Frost

Reputation: 229

How to check if LDAP user account is expired in Java using UnboundID LDAP SDK

I have a working LdapConnection object that I can use to bind and search with, but I am quite new to UnboundID LDAP SDK and was wondering if there is a way for me to find information about the users account from an LDAP search:

I currently use LdapConnection to search for usernames like this:

SearchResult searchResult = ldapConnection.search(configuration.sBase, scope, filter)

Is there a way I can use this connection to find expired/disabled accounts?

So it looks like expired users are found with this:

(&(objectCategory=Person)(objectClass=User)(!accountExpires=0)(!accountExpires=9223372036854775807)) 

can I make a filter with this string to search ldap and return all users with the LdapConnection object from unboundID Ldap?

Thanks

Upvotes: 0

Views: 1145

Answers (1)

Hamza Tahiri
Hamza Tahiri

Reputation: 506

In Active directory you can you use the attribute: UserStatus, its a boolean, if true the account is enabled, and otherwise its disabled, you can also set AccountExpires attributes while creating new users, by default its 0 so the account never expires, you can change that if you want temporary accounts.

Upvotes: 0

Related Questions