Ejemplo n.º 1
0
        /// <summary>
        /// 修改密码
        /// </summary>
        /// <returns></returns>
        public string UpdatePassWordAjax()
        {
            string UserID   = LgUser.UserId;
            string password = Request["va1"];


            string IsSuccess = "1";

            SqlParameter[] pms =
            {
                new SqlParameter("@UserID",   UserID),
                new SqlParameter("@password", Passwd.SetPass(password))
            };
            MessasgeInfor mginfor = Datafun.Mgfunctioninfor(@"update tb_login set Password=@password where id=@UserID", pms);


            if (mginfor.Mgdatacount > 0)
            {
                IsSuccess = "0";
            }
            else
            {
                IsSuccess = "1";
            }
            return(IsSuccess);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 绑定页面
        /// </summary>
        /// <param name="ID"></param>
        private void BindPage(string ID)
        {
            if (!String.IsNullOrWhiteSpace(ID))
            {
                Model.T_UsersInfo_MDL model = new DigiPower.Onlinecol.Standard.Model.T_UsersInfo_MDL();
                model = userBLL.GetModel(Convert.ToInt32(ID));
                if (model != null)
                {
                    ViewState["model"] = model;
                    object obj = DigiPower.Onlinecol.Standard.Web.Comm.SetValueToPage(model, this.tbl);
                    Passwd.Attributes("value", DESEncrypt.Decrypt(model.Passwd));

                    if (model.CompanyID > 0)
                    {
                        Model.T_Company_MDL companyMDL = new T_Company_BLL().GetModel(model.CompanyID);
                        if (companyMDL != null)
                        {
                            txtCompanyName.Text = companyMDL.CompanyName;
                        }
                    }
                    if (model.RoleID > 0)
                    {
                        Model.T_Role_MDL roleMDL = new T_Role_BLL().GetModel(model.RoleID);
                        if (roleMDL != null)
                        {
                            txtRoleName.Text = roleMDL.RoleName;
                        }
                    }
                }
            }
        }
        public override int GetHashCode()
        {
            int hash = 1;

            if (Id1 != 0)
            {
                hash ^= Id1.GetHashCode();
            }
            if (Id2 != 0)
            {
                hash ^= Id2.GetHashCode();
            }
            if (Username.Length != 0)
            {
                hash ^= Username.GetHashCode();
            }
            if (Passwd.Length != 0)
            {
                hash ^= Passwd.GetHashCode();
            }
            if (Ver.Length != 0)
            {
                hash ^= Ver.GetHashCode();
            }
            if (Json.Length != 0)
            {
                hash ^= Json.GetHashCode();
            }
            return(hash);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 添加负责人
        /// </summary>
        /// <returns></returns>
        public string AddfzrAjax()
        {
            string Meeting    = Request["va1"];
            string UserName   = Request["va2"];
            string Password   = Request["va3"];
            string Start_Date = Request["va4"];
            string End_Date   = Request["va5"];
            string tel        = Request["va6"];
            string IsSuccess  = "1";

            SqlParameter[] pms =
            {
                new SqlParameter("@Meeting",    Meeting),
                new SqlParameter("@Bank",       UserName),
                new SqlParameter("@Password",   Passwd.SetPass(Password)),
                new SqlParameter("@Start_Date", Start_Date),
                new SqlParameter("@End_Date",   End_Date),
                new SqlParameter("@UserName",   tel)
            };
            MessasgeData mgdata = Datafun.MgfunctionData("bs_NewMeeting_poc", pms, "poc");


            if (Convert.ToInt32(mgdata.Mgdata.Rows[0][0].ToString()) > 0)
            {
                IsSuccess = "0";
            }
            else
            {
                IsSuccess = "1";
            }
            return(IsSuccess);
        }
Ejemplo n.º 5
0
 public static void chown(string Path, string Username)
 {
     CheckRoot();
     //if (!File.Exists(Path))
     //    throw new FileNotFoundException(Path);
     if (Username == null)
     {
         throw new ArgumentNullException("Username");
     }
     else if (string.IsNullOrWhiteSpace("Username"))
     {
         throw new ArgumentException("Username");
     }
     else
     {
         Passwd passwordStruct = Syscall.getpwnam(Username);
         if (passwordStruct == null)
         {
             throw new UnixIOException(string.Format("User {0} not found", Username));
         }
         else if (Syscall.chown(Path, passwordStruct.pw_uid, passwordStruct.pw_gid) != 0)
         {
             throw new Exception("chown failed");
         }
     }
 }
Ejemplo n.º 6
0
        private void DoSetUser(ManosApp app, object user_data)
        {
#if DISABLE_POSIX
            throw new InvalidOperationException("Attempt to set user on a non-posix build.");
#else
            string user = user_data as string;

            Console.WriteLine("setting user to: '{0}'", user);

            if (user == null)
            {
                AppHost.Stop();
                throw new InvalidOperationException(String.Format("Attempting to set user to null."));
            }

            Passwd pwd = Syscall.getpwnam(user);
            if (pwd == null)
            {
                AppHost.Stop();
                throw new InvalidOperationException(String.Format("Unable to find user '{0}'.", user));
            }

            int error = Syscall.seteuid(pwd.pw_uid);
            if (error != 0)
            {
                AppHost.Stop();
                throw new InvalidOperationException(String.Format("Unable to switch to user '{0}' error: '{1}'.", user, error));
            }
#endif
        }
Ejemplo n.º 7
0
        public IActionResult EditPassword(int id)
        {
            if (_cache.Get(CacheNames.getMasterPassword).ToString() != "1") // ask user for masterpassword first time
            {
                return(RedirectToAction("MasterPassword"));
            }
            Passwd toEdit = _db.Passwds.Where(a => a.Id == id).FirstOrDefault(); // get password to decrypt by id
            User   usr    = Functions.getUser(_cache);

            if (toEdit.UserId != usr.Id)
            {
                _cache.Set(CacheNames.error4, "You can't edit that password");
                return(RedirectToAction("Index"));
            }
            var edit          = Convert.FromBase64String(toEdit.Password); // covnvert string into byte[] to decrypt
            var passwordOwner = _db.Users.Where(a => a.Id == toEdit.UserId).FirstOrDefault();

            toEdit.Password = AESHelper.DecryptToString(edit, passwordOwner.Password);  // decrypting password

            AppViewModel appViewModel = new AppViewModel
            {
                User   = Functions.getUser(_cache),
                Logged = Functions.getLogged(_cache),
                Passwd = toEdit
            };

            return(View(appViewModel));
        }
Ejemplo n.º 8
0
        public IActionResult ShareToUser(string username, int id)
        {
            User         userOwner   = Functions.getUser(_cache);
            Passwd       passwd      = _db.Passwds.Where(a => a.Id == id).FirstOrDefault();
            User         userToShare = _db.Users.Where(a => a.Nickname == username).FirstOrDefault();
            SharedPasswd shared      = _db.SharedPasswds.Where(a => a.PasswdId == id && a.UserSharedId == userToShare.Id).FirstOrDefault();

            if (userToShare == null)
            {
                _cache.Set(CacheNames.error3, "There is no users with that nickname");
                return(RedirectToAction("Share", new { id }));
            }
            if (shared != null)
            {
                _cache.Set(CacheNames.error3, "You are already sharing password with that user");
                return(RedirectToAction("Share", new { id }));
            }
            if (username == userOwner.Nickname)
            {
                _cache.Set(CacheNames.error3, "You can't share password with that user");
                return(RedirectToAction("Share", new { id }));
            }
            if (userOwner.Id == passwd.UserId)
            {
                SharedPasswd passToShare = new SharedPasswd()
                {
                    PasswdId     = passwd.Id,
                    UserOwnerId  = userOwner.Id,
                    UserSharedId = userToShare.Id
                };
                _db.SharedPasswds.Add(passToShare);
                _db.SaveChanges();
            }
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 9
0
        public UnixUserInfo(uint user)
        {
            Passwd passwd;

            this.passwd = new Passwd();
            if (Syscall.getpwuid_r(user, this.passwd, out passwd) != 0 || passwd == null)
            {
                throw new ArgumentException(Locale.GetText("invalid user id"), "user");
            }
        }
Ejemplo n.º 10
0
        public void SetOwner(string user)
        {
            this.AssertNotDisposed();
            Passwd passwd = Syscall.getpwnam(user);

            if (passwd == null)
            {
                throw new ArgumentException(Locale.GetText("invalid username"), "user");
            }
            this.SetOwner((long)passwd.pw_uid, (long)passwd.pw_gid);
        }
Ejemplo n.º 11
0
        public string LoginActionUser()
        {
            string username  = Request["va1"];
            string password  = Request["va2"];
            string IsSuccess = "0";
            string time      = DateTime.Now.ToString();
            string sql       = @"select * from tb_login where UserName=@UserName and Password=@Password and isdel=0 and  convert(nvarchar(11),Start_Date,120)<= convert(nvarchar(11),getdate(),120) and  convert(nvarchar(11),End_Date,120)>= convert(nvarchar(11),getdate(),120)";

            SqlParameter[] pms =
            {
                new SqlParameter("@UserName", username),

                new SqlParameter("@Password", Passwd.SetPass(password))
            };
            MessasgeData mgdata = Datafun.MgfunctionData(sql, pms);

            if (mgdata.Mgdatacount > 0)
            {
                DataRow   dr     = mgdata.Mgdata.Rows[0];
                LoginUser lguser = new LoginUser
                {
                    UserId   = dr["id"].ToString(),
                    UserName = dr["UserName"].ToString(),
                    UserPwd  = dr["Password"].ToString(),
                    UserLvl  = int.Parse(dr["Lvl"].ToString()),
                    Bank     = dr["Bank"].ToString(),
                    Tel      = dr["Tel"].ToString(),
                    Meetting = dr["Meeting"].ToString()
                };
                Session["Lguser"] = lguser;


                Response.Cookies["loginname"].Value   = Passwd.SetPass(username);
                Response.Cookies["loginpwd"].Value    = password;
                Response.Cookies["loginname"].Expires = DateTime.Now.AddDays(10);
                Response.Cookies["loginpwd"].Expires  = DateTime.Now.AddDays(10);

                mgdata.Mgcontent = "登陆成功";
                if (lguser.UserLvl == 0)
                {
                    IsSuccess = "1";
                }
                else
                {
                    IsSuccess = "2";
                }
            }
            else
            {
                mgdata.Mgcontent = "用户名密码错误";
                IsSuccess        = "0";
            }
            return(IsSuccess);
        }
Ejemplo n.º 12
0
        public void SetOwner(string owner)
        {
            Passwd passwd = Syscall.getpwnam(owner);

            if (passwd == null)
            {
                throw new ArgumentException(Locale.GetText("invalid username"), "owner");
            }
            uint pwUid = passwd.pw_uid;
            uint pwGid = passwd.pw_gid;

            this.SetOwner((long)pwUid, (long)pwGid);
        }
Ejemplo n.º 13
0
 /// <summary>
 /// 绑定页面
 /// </summary>
 /// <param name="ID"></param>
 private void BindPage(string ID)
 {
     if (!String.IsNullOrWhiteSpace(ID))
     {
         T_UsersInfo_MDL model = new T_UsersInfo_MDL();
         model = userBLL.GetModel(Common.ConvertEx.ToInt(ID));
         if (model != null)
         {
             ViewState["model"] = model;
             object obj = Comm.SetValueToPage(model, this.tbl);
             Passwd.Attributes("value", DESEncrypt.Decrypt(model.Passwd));
         }
     }
 }
Ejemplo n.º 14
0
        private static Passwd CopyPasswd(Passwd pw)
        {
            Passwd passwd = new Passwd()
            {
                pw_name   = pw.pw_name,
                pw_passwd = pw.pw_passwd,
                pw_uid    = pw.pw_uid,
                pw_gid    = pw.pw_gid,
                pw_gecos  = pw.pw_gecos,
                pw_dir    = pw.pw_dir,
                pw_shell  = pw.pw_shell
            };

            return(passwd);
        }
Ejemplo n.º 15
0
        public IActionResult Decrypt(int id)
        {
            if (_cache.Get(CacheNames.getMasterPassword).ToString() != "1") // ask user for masterpassword first time
            {
                return(RedirectToAction("MasterPassword"));
            }
            Passwd toDecrypt = _db.Passwds.Where(a => a.Id == id).FirstOrDefault(); // get password to decrypt by id
            User   usr       = Functions.getUser(_cache);

            if (toDecrypt.UserId != usr.Id)
            {
                var        sharedPass = _db.SharedPasswds.Where(a => a.UserSharedId == usr.Id).ToList();
                List <int> ids        = new List <int>();

                foreach (SharedPasswd sPass in sharedPass)
                {
                    ids.Add(sPass.PasswdId);
                }

                if (!ids.Contains(toDecrypt.Id))
                {
                    return(RedirectToAction("Index"));
                }
            }

            ActionType actionType = new ActionType()
            {
                Action = "Decrypt password id=" + id,
                UserId = usr.Id,
                Time   = DateTime.Now
            };

            Functions.AddActionToDatabase(_db, actionType);

            var decrypt       = Convert.FromBase64String(toDecrypt.Password); // covnvert string into byte[] to decrypt
            var passwordOwner = _db.Users.Where(a => a.Id == toDecrypt.UserId).FirstOrDefault();

            toDecrypt.Password = AESHelper.DecryptToString(decrypt, passwordOwner.Password);  // decrypting password

            AppViewModel appViewModel = new AppViewModel
            {
                User   = Functions.getUser(_cache),
                Logged = Functions.getLogged(_cache),
                Passwd = toDecrypt
            };

            return(View(appViewModel));
        }
Ejemplo n.º 16
0
                public override int GetHashCode()
                {
                    int hash = 1;

                    if (Uid != 0)
                    {
                        hash ^= Uid.GetHashCode();
                    }
                    if (Passwd.Length != 0)
                    {
                        hash ^= Passwd.GetHashCode();
                    }
                    if (Cmd != 0)
                    {
                        hash ^= Cmd.GetHashCode();
                    }
                    return(hash);
                }
Ejemplo n.º 17
0
        public string ExpandPath(string path)
        {
            Match m = path_matcher.Match(path);

            if (!m.Success)
            {
                return(path);
            }

            if (String.IsNullOrEmpty(m.Groups[1].Value))
            {
                return(UserHome + m.Groups[2].Value);
            }
            else
            {
                Passwd pw = Syscall.getpwnam(m.Groups[1].Value);
                return((pw == null) ? path : pw.pw_dir + m.Groups[2].Value);
            }
        }
Ejemplo n.º 18
0
        public IActionResult History(int id)
        {
            Passwd toEdit = _db.Passwds.Where(a => a.Id == id).FirstOrDefault(); // get password to decrypt by id
            User   usr    = Functions.getUser(_cache);

            if (toEdit.UserId != usr.Id)
            {
                _cache.Set(CacheNames.error4, "You can't check history");
                return(RedirectToAction("Index"));
            }

            AppViewModel appViewModel = new AppViewModel
            {
                User   = Functions.getUser(_cache),
                Logged = Functions.getLogged(_cache),
                Passwd = toEdit
            };

            return(View(appViewModel));
        }
Ejemplo n.º 19
0
        public UserModule() : base("/user")
        {
            Post["/apply"] = x => {
                Passwd.Set();
                return(HttpStatusCode.OK);
            };

            Post["/set/users/applicative"] = x => {
                string data    = Request.Form.Data;
                var    objects = JsonConvert.DeserializeObject <ApplicativeUser[]>(data);
                Application.CurrentConfiguration.Users.ApplicativeUsers = objects;
                ConfigRepo.Save();
                return(HttpStatusCode.OK);
            };

            Post["/set/users/system"] = x => {
                string data    = Request.Form.Data;
                var    objects = JsonConvert.DeserializeObject <SystemUser[]>(data);
                Application.CurrentConfiguration.Users.SystemUsers = objects;
                ConfigRepo.Save();
                return(HttpStatusCode.OK);
            };

            Get["/get/password"] = x => {
                string data = Request.Form.Data;
                var    pwd  = Passwd.HashPasswd(data);
                return(Response.AsText(pwd));
            };

            #region [    Authentication   ]
            Post["/authenticate"] = x => {
                string data  = Request.Form.Data;
                var    model = JsonConvert.DeserializeObject <AuthenticationDataModel>(data);
                return(Login.Authenticate(model.Id, model.Claims));
            };

            Get["/get/applicative"] = x => {
                return(JsonConvert.SerializeObject(Application.CurrentConfiguration.Users.ApplicativeUsers));
            };
            #endregion
        }
Ejemplo n.º 20
0
        public static UnixUserInfo[] GetLocalUsers()
        {
            ArrayList arrayLists = new ArrayList();
            object    pwdLock    = Syscall.pwd_lock;

            Monitor.Enter(pwdLock);
            try
            {
                if (Syscall.setpwent() != 0)
                {
                    UnixMarshal.ThrowExceptionForLastError();
                }
                try
                {
                    while (true)
                    {
                        Passwd passwd  = Syscall.getpwent();
                        Passwd passwd1 = passwd;
                        if (passwd == null)
                        {
                            break;
                        }
                        arrayLists.Add(new UnixUserInfo(passwd1));
                    }
                    if ((int)Stdlib.GetLastError() != 0)
                    {
                        UnixMarshal.ThrowExceptionForLastError();
                    }
                }
                finally
                {
                    Syscall.endpwent();
                }
            }
            finally
            {
                Monitor.Exit(pwdLock);
            }
            return((UnixUserInfo[])arrayLists.ToArray(typeof(UnixUserInfo)));
        }
Ejemplo n.º 21
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Account.Length != 0)
            {
                hash ^= Account.GetHashCode();
            }
            if (Passwd.Length != 0)
            {
                hash ^= Passwd.GetHashCode();
            }
            if (ZoneId != 0)
            {
                hash ^= ZoneId.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Ejemplo n.º 22
0
        public IActionResult Share(int id)
        {
            User   userOwner = Functions.getUser(_cache);
            Passwd passwd    = _db.Passwds.Where(a => a.Id == id).FirstOrDefault();

            if (userOwner.Id != passwd.UserId)
            {
                _cache.Set(CacheNames.error4, "You are not the owner");
                return(RedirectToAction("Index"));
            }

            AppViewModel appViewModel = new AppViewModel
            {
                User   = Functions.getUser(_cache),
                Logged = Functions.getLogged(_cache),
                Passwd = _db.Passwds.Where(a => a.Id == id).FirstOrDefault(),
                Error  = Functions.getError(_cache, CacheNames.error3)
            };

            _cache.Remove(CacheNames.error3);
            return(View(appViewModel));
        }
Ejemplo n.º 23
0
 public static void setuid(string Username)
 {
     CheckRoot();
     if (Username == null)
     {
         throw new ArgumentNullException("Username");
     }
     else if (string.IsNullOrWhiteSpace(Username))
     {
         throw new ArgumentException("Username");
     }
     else
     {
         Passwd passwordStruct = Syscall.getpwnam(Username);
         if (passwordStruct == null)
         {
             throw new UnixIOException(string.Format("User {0} not found", Username));
         }
         else if (Syscall.setuid(passwordStruct.pw_uid) != 0)
         {
             throw new Exception("setuid failed");
         }
     }
 }
Ejemplo n.º 24
0
 internal static extern unsafe int GetPwUidR(uint uid, out Passwd pwd, byte *buf, int bufLen);
Ejemplo n.º 25
0
 internal static extern unsafe int GetPwNamR(string name, out Passwd pwd, byte *buf, int bufLen);
Ejemplo n.º 26
0
 internal static extern unsafe int GetPwUid(int uid, out Passwd pwd, byte* buf, long bufLen, out IntPtr result);
Ejemplo n.º 27
0
 internal static extern unsafe int GetPwUid(int uid, out Passwd pwd, byte *buf, long bufLen, out IntPtr result);
Ejemplo n.º 28
0
 internal static extern unsafe int GetPwUidR(uint uid, out Passwd pwd, byte* buf, int bufLen);
Ejemplo n.º 29
0
 internal static unsafe partial int GetPwNamR(string name, out Passwd pwd, byte *buf, int bufLen);
Ejemplo n.º 30
0
 internal static unsafe partial int GetPwUidR(uint uid, out Passwd pwd, byte *buf, int bufLen);
Ejemplo n.º 31
0
 internal static extern unsafe int getpwuid_r(uint uid, out Passwd pwd, byte *buf, int bufLen, out IntPtr result);
Ejemplo n.º 32
0
 internal static extern int GetPwUidR(uint uid, out Passwd pwd, IntPtr buf, int bufLen);