internal static void User_Unlock(string userName, string domain) { ADWrapper ad = new ADWrapper(domain, Common.CnnStringNameAD, performCustomWindowsContextImpersonalization); try { UnlockAccount2(userName, ad); } catch (Exception y) { if (performCustomWindowsContextImpersonalization) { using (var impersonation = new ImpersonateUser(ad.LDAPUser, ad.LDAPDomain, ad.LDAPPassword, ImpersonateUser.LOGON32_LOGON_NEW_CREDENTIALS)) { ad.User_Unlock(userName); } } else { ad.User_Unlock(userName); } ad.Dispose(); } }
internal static void User_Unlock(string userName, string domain) { ADWrapper ad = new ADWrapper(domain, ActiveDirectoryService.CnnStringName, performCustomWindowsContextImpersonalization); //ad.User_SetLockedStatus(userName, false); ad.User_Unlock(userName); ad.Dispose(); }
internal static void User_Unlock(string userName, string domain) { ADWrapper ad = new ADWrapper(domain, Common.CnnStringNameAD, false); //ad.User_SetLockedStatus(userName, false); if (performCustomWindowsContextImpersonalization) { var safeAccessTokenHandle = TryImpersonate(ad); WindowsIdentity.RunImpersonated(safeAccessTokenHandle, () => { ad.User_Unlock(userName); }); } else { ad.User_Unlock(userName); } ad.Dispose(); }