Password and LDAP

A

ABUnNOUR

hi
how can i know the expiry date for users PASSWORD in active directory
?

i want to detect the date to notify the user about ?

am using Asp.net with C# in my application .. So can you please tell me
how ?
 
T

Tasos Vogiatzoglou

Use this .

First parameter domain path (e.g. LDAP://Domain)
second parameter userPath (e.g. LDAP://Domain/CN=<username> ...)

public DateTime GetDomainPasswordExpiration(string domainPath, string
userPath)
{
DirectoryEntry domain = new DirectoryEntry(domainPath);
DirectoryEntry user = new DirectoryEntry(userPath);

LargeInteger pwdLastSet =
(LargeInteger)user.Properties["pwdLastSet"].Value;
LargeInteger maxPwdAge =
(LargeInteger)domain.Properties["maxPwdAge"].Value;

long daysL = (((long)maxPwdAge.HighPart<<32) + maxPwdAge.LowPart);
long dt = (((long)(pwdLastSet.HighPart) << 32) + (long)
pwdLastSet.LowPart) - daysL;
return DateTime.FromFileTime(dt);
}


You have to make a reference to "ActiveDS Type Library" (COM)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top