活动目录 - 检查密码永不过期?密码、目录

2023-09-08 12:57:42 作者:迟遇

有没有办法在Visual Basic中检查,如果用户的密码设置为永不过期在Active Directory?

我已经找到一种方法找到它上次更改日期,但我找不到其他可用的选项。

 昏暗德作为DirectoryServices.DirectoryEntry =的getUser(uDetails.username)
昏暗objUser = GetObject的(de.Path)
如果objUser.PasswordLastChanged< DateTime.Now.AddMonths然后(-3)
...
 

我在哪里可以找到所有可用的 objUser 属性的列表?

解决方案

 公共BOOL isPasswordExpired(字符串p_UserName,字符串p_DomainName)
{
    布尔m_Check = FALSE;

    INT m_Val1 =(int)的de1.Properties [userAccountControl的]值。
    INT m_Val2 =(INT)0x10000的;

    如果(Convert.ToBoolean(m_Val1&安培; m_Val2))
    {
        m_Check =真;
    } //结束

    返回m_Check
}
 

如何用powershell查看密码永不过期的域用户

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?

解决方案

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
}