I need to query Active Directory for a list of users whose password expires. An obvious (and easy) way to do this:
dsquery user -stalepwd n
The problem is that I need to add additional filters to search for users who are in certain security groups. This is difficult to do with the dsquery user syntax, which has the -stalepwd option built in, so I used the "dsquery * -filter" parameter, which allows us to use the LDAP query syntax. Unfortunately, although it is relatively easy to apply other filters with an LDAP query, I have problems filtering users who have a password age greater than n.
Does anyone know the syntax (or if at all possible) for filtering old passwords using the dsquery * -filter method instead of the dsquery user -stalepwd method.
Geoff armstrong
source share