Search code examples
asp.netvb.netactive-directory.net-2.0

Active Directory - check if password never expires?


Is there a way in Visual Basic to check if the user's password is set to never expire in Active Directory?

I've found a way to find the last date it was changed, but I can't find the other available options.

Dim de As DirectoryServices.DirectoryEntry = GetUser(uDetails.username)
Dim objUser = GetObject(de.Path)
If objUser.PasswordLastChanged < DateTime.Now.AddMonths(-3) Then
...

Where can I find a list of all available objUser properties?


Solution

  • public bool isPasswordExpired(String p_UserName, String p_DomainName)
    {
        bool m_Check=false;
    
        int m_Val1 = (int)de1.Properties["userAccountControl"].Value;
        int m_Val2 = (int) 0x10000;
    
        if (Convert.ToBoolean(m_Val1 & m_Val2))
        {
            m_Check = true;
        } //end
    
        return m_Check
    }