2008-11-24 9 views

Respuesta

5

Ver Security Watch Windows Domain Password Policies. Puede presionar AD usando ADSI o sus envoltorios. Encontré un VBScript sample. Se puede traducir a cualquier idioma que desee:

Sub ListPasswordPolicyInfo(strDomain) 
    Dim objComputer 
    Set objComputer = GetObject("WinNT://" & strDomain) 
    WScript.Echo "MinPasswordAge: " & ((objComputer.MinPasswordAge)/86400) 
    WScript.Echo "MinPasswordLength: " & objComputer.MinPasswordLength 
    WScript.Echo "PasswordHistoryLength: " & objComputer.PasswordHistoryLength 
    WScript.Echo "AutoUnlockInterval: " & objComputer.AutoUnlockInterval 
    WScript.Echo "LockOutObservationInterval: " & objComputer.LockOutObservationInterval 
End Sub 

Dim strDomain 
Do 
    strDomain = inputbox("Please enter a domainname", "Input") 
Loop until strDomain <> "" 

ListPasswordPolicyInfo(strDomain) 

Como beneficio adicional, echa un vistazo a LDAP Admin. Es un editor de directorio LDAP de código abierto, que puede usar para probar cosas, y también puede consultar el código escrito en Delphi.

3

La respuesta de Eugene es útil, pero no es exactamente lo que necesitaba. El filtro de complejidad de contraseña puede personalizarse realmente, y lo que sería bueno sería una forma de preguntarle a Windows, ¿esta contraseña cumple con los requisitos?

Me llevó algo de tiempo localizarlo, pero la función es NetValidatePasswordPolicy. Los documentos de MSDN para esta función son terribles; mira esto MSDN blog entry en su lugar.

1

Consultar ActiveDirectory solo funciona para computadoras unidas a un dominio; y donde el usuario tiene la capacidad de consultar el controlador de dominio (que es algo que no se puede otorgar).

@ La respuesta de NicholasWilson de usar NetValidatePasswordPolicy es buena; ya que puede hacer mucho trabajo pesado para usted. Incluso puede realizar comprobaciones de la calidad de las contraseñas que tendría que volver a implementar usted mismo. Pero NetValidatePasswordPolicy falla al examinar su historial de contraseñas personalizadas cuando usa hashes saturados para almacenar contraseñas (por ejemplo, BCrypt o Scrypt).

Pero la verdadera pregunta es cómo consultar la política de contraseñas de la máquina actual (incluso una máquina no conectada a un dominio). Se pueden realizar consultas que el uso de:

NetUserModalsGet

struct USER_MODALS_INFO_0 
{ 
    DWORD usrmod0_min_passwd_len; 
    DWORD usrmod0_max_passwd_age; 
    DWORD usrmod0_min_passwd_age 
    DWORD usrmod0_force_logoff; 
    DWORD usrmod0_password_hist_len; 
} 
PUSER_MODALS_INFO_0 = ^USER_MODALS_INFO_0;  

PUSER_MODALS_INFO_0 info0; 

NET_API_STATUS res = NetUserModalsGet(nil, 0, out info0); 

if (res <> NERR_Success) 
    RaiseWin32Error(res); 
try 
    //Specifies the minimum allowable password length. 
    //Valid values for this element are zero through PWLEN. 
    Log(info0.usrmod0_min_passwd_len); 

    //Specifies, in seconds, the maximum allowable password age. 
    //A value of TIMEQ_FOREVER indicates that the password never expires. 
    //The minimum valid value for this element is ONE_DAY. 
    //The value specified must be greater than or equal to the value for the usrmod0_min_passwd_age member. 
    Log(info0.usrmod0_max_passwd_age); 

    //Specifies the minimum number of seconds that can elapse between the time 
    //a password changes and when it can be changed again. 
    //A value of zero indicates that no delay is required between password updates. 
    //The value specified must be less than or equal to the value for the usrmod0_max_passwd_age member. 
    Log(info0.usrmod0_min_passwd_age); 

    //Specifies, in seconds, the amount of time between the end of the valid 
    // logon time and the time when the user is forced to log off the network. 
    //A value of TIMEQ_FOREVER indicates that the user is never forced to log off. 
    //A value of zero indicates that the user will be forced to log off immediately when the valid logon time expires. 
    Log(info0.usrmod0_force_logoff); 

    //Specifies the length of password hi'+'story maintained. 
    //A new password cannot match any of the previous usrmod0_password_hist_len passwords. 
    //Valid values for this element are zero through DEF_MAX_PWHIST 
    Log(info0.usrmod0_password_hist_len); 
finally 
    NetApiBufferFree(info0); 
end; 
Cuestiones relacionadas