Ejemplo n.º 1
0
    public bool ResetPassowrd(string userid, ICommonService configuration, string webRootPath, ref string msg)
    {
        bool success = false;

        try
        {
            var found = AdUsers.Where(x => x.ID == userid).ToList();
            if (found.Count > 0)
            {
                string tempPass = PasswordGenerator.GeneratePassword(true, true, true, false, false, 8);
                string hash     = AuthHelper.HashString(tempPass);
                found[0].PWord   = hash;
                found[0].chgpass = true;
                SaveChanges(true);

                success = EmailHelper.SendTempPassEmail(userid, tempPass, configuration, webRootPath, ref msg);
            }
            else
            {
                msg = "email not registered...";
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
            msg = ex.InnerException.Message;
        }

        return(success);
    }
Ejemplo n.º 2
0
        public Task <List <AdUser> > SearchDomainUsers(string search) => Task.Run(() =>
        {
            search = search.ToLower();

            var users = AdUsers
                        .Where(
                x => x.SamAccountName.ToLower().Contains(search) ||
                x.UserPrincipalName.ToLower().Contains(search) ||
                x.DisplayName.ToLower().Contains(search)
                )
                        .OrderBy(x => x.Surname)
                        .ToList();

            return(users);
        });
Ejemplo n.º 3
0
    public bool ChangePassowrd(UserInfo user, ref string msg)
    {
        bool success = false;

        try
        {
            var found = AdUsers.Where(x => x.ID == user.name).ToList();
            if (found.Count > 0)
            {
                found[0].PWord   = user.fullname;
                found[0].chgpass = false;
                SaveChanges(true);
                success = true;
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
            msg = ex.InnerException.Message;
        }

        return(success);
    }