private void UpdateDetails()
        {
            SuspendLayout();

            tbUser.Text     = "";
            tbPassword.Text = "";

            tbPassword.Enabled     = _currentUser != null;
            btnGenerate.Enabled    = _currentUser != null;
            btnSetPassword.Enabled = _currentUser != null;
            btnUnlock.Enabled      = _currentUser != null;

            if (_currentUser == null)
            {
                return;
            }

            var passwordExpiry  = ADHelpers.PasswordExpirationDate(_currentUser);
            var passwordExpired = passwordExpiry <= DateTime.UtcNow ? "YES" : "NO";

            var s = string.Format("{1}{0}{0}Login: {2}{0}{0}Password expiry: {3}{0}Password expired: {4}",
                                  Environment.NewLine, _currentUser.DisplayName, _currentUser.UserPrincipalName, passwordExpiry, passwordExpired);

            if (_currentUser.IsAccountLockedOut())
            {
                s += string.Format("{0}{0}ACCOUNT IS LOCKED", Environment.NewLine);
            }
            tbUser.Text = s;


            btnUnlock.Enabled = _currentUser.IsAccountLockedOut();

            ResumeLayout();
        }
        private void LoadUsers()
        {
            var dn     = UserPrincipal.Current.DistinguishedName;
            var domain = WindowsIdentity.GetCurrent().Name.Split(new char[] { '\\' }).First();

            var items   = dn.Split(new char[] { ',' }).Where(x => !x.Contains("CN="));
            var pattern = string.Join(",", items);
            var users   = ADHelpers.GetUsersInOu(domain, pattern);

            lbUsers.Items.Clear();
            foreach (var user in users)
            {
                if (user.Enabled == null || user.Enabled == false)
                {
                    continue;
                }

                lbUsers.Items.Add(user);
            }
        }