2008-11-24 10 views
7

क्या ऐसे विंडोज एपीआई फ़ंक्शंस हैं जो वर्तमान पासवर्ड नीति को पढ़ने की अनुमति देते हैं? उदाहरण के लिए, न्यूनतम लंबाई, जटिलता इत्यादिस्थानीय पासवर्ड नीति को प्रोग्रामेटिक रूप से पढ़ना

यदि पढ़ नहीं रहा है, तो प्रोग्राम के माध्यम से नीति के खिलाफ पासवर्ड सत्यापित करने का कोई तरीका है?

उत्तर

5

Security Watch Windows Domain Password Policies देखें। आप ADSI या उसके रैपर का उपयोग करके एडी दबा सकते हैं। मुझे VBScript sample मिला। आप इसे आप चाहते हैं किसी भी भाषा में अनुवाद कर सकते हैं:

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) 

एक बोनस के रूप में, LDAP Admin की जाँच करें। यह एक ओपन सोर्स एलडीएपी निर्देशिका संपादक है, जिसका उपयोग आप चीजों का परीक्षण करने के लिए कर सकते हैं, और डेल्फी में लिखे गए कोड को चेकआउट भी कर सकते हैं।

3

यूजीन का जवाब सहायक है, लेकिन मुझे जो चाहिए वह काफी नहीं है। पासवर्ड जटिलता फ़िल्टर वास्तव में अनुकूलित किया जा सकता है, और विंडोज़ पूछने का एक तरीका क्या होगा, क्या यह पासवर्ड आवश्यकताओं को पूरा करता है?

इसे ढूंढने में मुझे कुछ समय लगा, लेकिन समारोह NetValidatePasswordPolicy है। इस समारोह के लिए एमएसडीएन दस्तावेज़ भयानक हैं; इसके बजाय MSDN blog entry देखें।

1

पूछताछ सक्रिय डायरेक्टरी केवल कंप्यूटर के लिए कंप्यूटर के लिए काम करता है; और जहां उपयोगकर्ता के पास डोमेन नियंत्रक से पूछताछ करने की क्षमता होती है (जो कुछ ऐसा है जिसे अन-अनुमोदित किया जा सकता है)।

@ निकोलस विल्सन का NetValidatePasswordPolicy का उपयोग करने का उत्तर एक अच्छा है; क्योंकि यह आपके लिए बहुत भारी भारोत्तोलन कर सकता है। यह पासवर्ड गुणवत्ता जांच भी कर सकता है जिसे आपको स्वयं को फिर से कार्यान्वित करना होगा। लेकिन NetValidatePasswordPolicy आपके कस्टम पासवर्ड इतिहास की जांच के रूप में विफल रहता है जब आप पासवर्ड स्टोर करने के लिए नमकीन हैंश का उपयोग करते हैं (उदा। बीक्रिप्ट या स्क्रिप)।

लेकिन असली सवाल यह है कि मौजूदा मशीन (यहां तक ​​कि एक गैर-डोमेन शामिल मशीन की) पासवर्ड नीति के लिए पूछताछ कैसे करें। आप क्वेरी कर सकता है कि का उपयोग कर:

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; 
संबंधित मुद्दे