How to check ADuser “Password never expires” properties check or not using C++ Win32API?

StackOverflow https://stackoverflow.com/questions/13194624

Вопрос

i am using C++ Win32 API...

i want to know the user password policies properties value...

that is "Password never expires" ,how to check this property is checked or not using C++ Win32 API?

Это было полезно?

Решение

You can use COM interface IADsUser. See this MSDN example for enabling "never expires" flag

You can use it first part before to row V_I4(&var) |= ADS_UF_DONT_EXPIRE_PASSWD; - replace it with if (V_I4(&var) & ADS_UF_DONT_EXPIRE_PASSWD) { /* option is enabled! your code here */}

Hope this helps. And this is work :)

Другие советы

Please check out this...Hope it can resolve your issues

WriteLogMessage("Processing:" + UserEntry.Name);

                    WriteLogMessage("Max Password Age:" + iMaxPwdAge);

                    //Console.WriteLine("Account control:" + UserEntry.Properties["userAccountcontrol"].Value);

                    int userAccountControl = Convert.ToInt32(UserEntry.Properties["userAccountcontrol"].Value);
                    if ((userAccountControl & ADS_DONT_EXPIRE_PASSWORD) > 0)
                    {
                        WriteLogMessage("Password never expires for:" + UserEntry.Name);
                    }
                    else
                    {
                        WriteLogMessage("Password expiration date found for:" + UserEntry.Name);

                        ActiveDs.IADsUser native = (ActiveDs.IADsUser)UserEntry.NativeObject;

                        DateTime passwordLastChanged = new DateTime(9999, 1, 1);
                        try

Else without script if you want to use please use a third party tool. It will automatically update you to password has expired and password never expired.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top