Expiration of Active Directory accounts
Requesting their support if I can guide in order to obtain a li开发者_如何学运维st of users that is soon to expire your account on my active directory.
See this great MSDN magazine article Managing Directory Security Principals in the .NET Framework 3.5
In section 8, the authors talk about how to query for common things like finding users whose accounts will expire in a given period of time.
By doing something quite simple like this, you can find all users whose account will expire by Dec 15:
// establish domain context
PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
// find users whose accounts will expire by Dec 15
PrincipalSearchResult<UserPrincipal> users =
UserPrincipal.FindByExpirationTime(ctx, new DateTime(2010, 12, 15),
MatchType.LessThanOrEquals);
Now you have a list of UserPrincipal
accounts that will expire soon.
精彩评论