Esempio n. 1
0
    public static MPSUser NewUser()
    {
        string name  = DateTime.Now.Ticks.ToString();
        string email = name + "@domain.com";

        AddObject(_Tabl, new string[] { _login, _pname, _pass, _isAdm, _ret, _birth, _lvl, _email }, new object[] { name, name, "", 0, 0, DateTime.Now, 3, email }, "");
        DefectUser.NewUser(name, "", email);
        ReferenceVersion.Updatekey();
        foreach (int i in EnumRecords(_Tabl, _pid, new string[] { _login }, new object[] { name }))
        {
            return(new MPSUser(i));
        }
        return(null);
    }
Esempio n. 2
0
    public static MPSUser FindUser(string name, string pass)
    {
        bool domain = name.Contains("@");

        if (domain)
        {
            bool   valid        = false;
            string dispUserName = name;
            using (PrincipalContext context = new PrincipalContext(ContextType.Domain, Settings.CurrentSettings.COMPANYDOMAIN))
            {
                valid = context.ValidateCredentials(name, pass);
                if (valid)
                {
                    var usr = UserPrincipal.FindByIdentity(context, name);
                    if (usr != null)
                    {
                        dispUserName = usr.GivenName + " " + usr.Surname;
                    }
                }
            }
            if (!valid)
            {
                return(null);
            }
            foreach (int i in EnumRecords(_Tabl, _pid, new string[] { _login }, new object[] { name }))
            {
                return(new MPSUser(i));
            }
            AddObject(_Tabl, new string[] { _login, _pname, _pass, _isAdm, _ret, _birth, _lvl, _email }, new object[] { name, dispUserName, "", 0, 0, DateTime.Now, 3, name }, "");
            DefectUser.NewUser(name, "", name);
            ReferenceVersion.Updatekey();
            foreach (int i in EnumRecords(_Tabl, _pid, new string[] { _login }, new object[] { name }))
            {
                return(new MPSUser(i));
            }
            return(null);
        }
        foreach (int i in EnumRecords(_Tabl, _pid, new string[] { _login, _pass }, new object[] { name, pass }))
        {
            return(new MPSUser(i));
        }
        return(null);
    }