/// <summary> /// required implementation /// </summary> /// <param name="user">required implementation</param> public void UpdateUser(user muser) { log.Info("UpdateUser:"******" in Application: " + _App.AppName); try { if (muser == null) return; UserSrv.Update(muser); UserSrv.CommitChanges(); } catch (Exception ex) { log.Error("Error UpdateUser: "******" in Application: " + _App.AppName, ex); return; } }
user UpdateUserFromMembership(MembershipUser mMembership, user TempUser) { TempUser.username = mMembership.UserName; TempUser.email = mMembership.Email; TempUser.PasswordQuestion = mMembership.PasswordQuestion; TempUser.IsApproved = mMembership.IsApproved; TempUser.IsLockedOut = mMembership.IsLockedOut; TempUser.CreateDate = mMembership.CreationDate; TempUser.LastLoginDate = mMembership.LastLoginDate; TempUser.LastPasswordChangedDate = mMembership.LastPasswordChangedDate; TempUser.LastLockoutDate = mMembership.LastLockoutDate; return TempUser; }
public user CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, string groupName, out string status) { log.Info("Create new User: "******" in Application " + _App.AppName); user TempUser = UserSrv.GetByName(username); if (TempUser != null) { status = "DuplicateUserName"; return null; } TempUser = new user(); TempUser.username = username; TempUser.password = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "MD5"); TempUser.PasswordSalt = "MD5"; TempUser.PasswordFormat = (int)PasswordFormat; TempUser.email = email; TempUser.PasswordQuestion = passwordQuestion; TempUser.PasswordAnswer = passwordAnswer; TempUser.IsApproved = isApproved; TempUser.GroupName = groupName; TempUser.ApplicationList = new List<Applications>(); TempUser.ApplicationList.Add(_App); try { TempUser = UserSrv.CreateNew(TempUser); UserSrv.CommitChanges(); status = "Success"; return TempUser; } catch (Exception ex) { log.Error("CreateUser Error", ex); status = "ProviderError"; return null; } }
user ConvertMembershipToUser(MembershipUser mMembership) { int userID = -1; if(mMembership.ProviderUserKey is int) userID = (int)mMembership.ProviderUserKey; user TempUser = _UserSrv.Getbykey(userID); if(TempUser == null)TempUser = new user(); TempUser.username = mMembership.UserName; TempUser.email = mMembership.Email; TempUser.PasswordQuestion = mMembership.PasswordQuestion; TempUser.IsApproved = mMembership.IsApproved; TempUser.IsLockedOut = mMembership.IsLockedOut; TempUser.CreateDate = mMembership.CreationDate; TempUser.LastLoginDate = mMembership.LastLoginDate; TempUser.LastPasswordChangedDate = mMembership.LastPasswordChangedDate; TempUser.LastLockoutDate = mMembership.LastLockoutDate; return TempUser; }
MembershipUser ConvertUserToMembership(user mUser) { return new MembershipUser(this.Name, mUser.username, mUser.userid, mUser.email, mUser.PasswordQuestion, "", mUser.IsApproved, mUser.IsLockedOut, mUser.CreateDate, mUser.LastLoginDate, mUser.CreateDate, mUser.LastPasswordChangedDate, mUser.LastLockoutDate); }
public void AddUser(user mUser) { user TempUser = Mapping(mUser); if (TempUser == null) { mUser.ApplicationList = new List<Applications>(); mUser.ApplicationList.Add(App); UserSrv.CreateNew(mUser); } else { if (!TempUser.ApplicationList.Contains(App)) { TempUser.ApplicationList.Add(App); } } UserSrv.CommitChanges(); }
/// <summary> /// required implementation /// </summary> /// <param name="username">required implementation</param> /// <param name="password">required implementation</param> /// <param name="email">required implementation</param> /// <param name="passwordQuestion">required implementation</param> /// <param name="passwordAnswer">required implementation</param> /// <param name="isApproved">required implementation</param> /// <param name="providerUserKey">required implementation</param> /// <param name="status">required implementation</param> /// <returns>a user object</returns> public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status) { log.Info("Create new User: "******" in Application " + _App.AppName); ValidatePasswordEventArgs args = new ValidatePasswordEventArgs(username, password, true); OnValidatingPassword(args); if (args.Cancel) { status = MembershipCreateStatus.InvalidPassword; return null; } if (RequiresUniqueEmail && GetUserNameByEmail(email) != "") { status = MembershipCreateStatus.DuplicateEmail; return null; } user TempUser = UserSrv.GetByName(username); if (TempUser != null) { status = MembershipCreateStatus.DuplicateUserName; return null; } TempUser = new user(); TempUser.username = username; TempUser.password = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "MD5"); TempUser.PasswordSalt = "MD5"; TempUser.PasswordFormat = (int)PasswordFormat; TempUser.email = email; TempUser.PasswordQuestion = passwordQuestion; TempUser.PasswordAnswer = passwordAnswer; TempUser.IsApproved = isApproved; TempUser.ApplicationList = new List<Applications>(); TempUser.ApplicationList.Add(_App); try { TempUser = UserSrv.CreateNew(TempUser); UserSrv.CommitChanges(); status = MembershipCreateStatus.Success; return ConvertUserToMembership(TempUser); } catch (Exception ex) { log.Error("CreateUser Error", ex); status = MembershipCreateStatus.ProviderError; return null; } }
//maping an object to a persistant object in Nhibernate private user Mapping(user mUser) { user temp; if (mUser.userid > 0) temp = UserSrv.Getbykey(mUser.userid); else { temp = UserSrv.GetByName(mUser.username); } return temp; }
public void AddActiveRole(user mUser, session mSession, role mRole) { throw new Exception("This method have not Implement."); }
public IList<operation> UserOperationsOnObject(user mUser, objectRbac mObject) { IList<operation> _ret = new List<operation>(); objectRbac TempObject = Mapping(mObject); IList<role> Role_Lst = AuthorizedRoles(mUser); foreach (role r in Role_Lst) { List<operation> operationLst = (from per in r.Permissions where (per.ObjectRBAC == TempObject) select per.Operation).ToList<operation>(); foreach (operation op in operationLst) { if (!_ret.Contains(op)) _ret.Add(op); } } return _ret; }
public IList<permission> UserPermissions(user mUser) { IList<permission> ret = new List<permission>() ; IList<role> RoleList = AuthorizedRoles(mUser); foreach (role r in RoleList) { IList<permission> _permissionList = RolePermissions(r); foreach (permission per in _permissionList) { if (!ret.Contains(per)) ret.Add(per); } } return ret; }
public void DeleteUser(user mUser) { user temp = Mapping(mUser); if (temp == null) throw new Exception("This user does not exist in system"); else { if (temp.ApplicationList.Contains(App)) { temp.ApplicationList.Remove(App); if (temp.ApplicationList.Count == 0) UserSrv.Delete(temp); UserSrv.CommitChanges(); } } }
public void DeleteSession(user mUser, session mSession) { throw new Exception("This method have not Implement."); }
public void DeassignUser(user mUser, role mRole) { user TempUser = Mapping(mUser); if (TempUser == null) throw new Exception("User does not exist in system."); role TempRole = Mapping(mRole); if (TempRole == null) throw new Exception("Role does not exist in system."); if (TempUser.Roles.Contains(TempRole)) TempUser.Roles.Remove(TempRole); UserSrv.CommitChanges(); }
public IList<role> AuthorizedRoles(user mUser) { user TempUser = Mapping(mUser); if (TempUser != null) return (from _role in TempUser.Roles where (_role.AppID == App.AppID) select _role).ToList<role>(); else return null; }
public int UpdateProfileForUser(user mUser, string[] PropertyNames, object[] PropertyValues) { for (int i = 0; i < PropertyNames.Length; i++) { object value = i >= PropertyValues.Length ? "" : PropertyValues[i]; if (mUser.UserProfiles.ContainsKey(PropertyNames[i])) { if (value is byte[]) mUser.UserProfiles[PropertyNames[i]].PropertyValuesBinary = value as byte[]; else mUser.UserProfiles[PropertyNames[i]].PropertyValuesString = value.ToString(); } else { UserProfile uf = new UserProfile(PropertyNames[i], value); mUser.UserProfiles.Add(PropertyNames[i],uf); } } IuserService _service = new userService(this.SessionFactoryConfigPath); try { _service.Update(mUser); return 1; } catch (Exception ex) { log.Error("Update profile Error.", ex); return -1; } }