public override void AddUsersToRoles(string[] usernames, string[] roleNames) { if (_App == null) { return; } foreach (string UN in usernames) { user mUser = UserSrv.GetByName(UN, _App.AppID); if (mUser != null) { string[] currentRoles = (from r in mUser.Roles where r.AppID == _App.AppID select r.name).ToArray(); foreach (string r in roleNames) { if (!currentRoles.Contains(r)) { role mRole = RoleSrv.GetByName(r, _App.AppID); if (mRole != null) { mUser.Roles.Add(mRole); } } } } } UserSrv.CommitChanges(); }
public override bool RoleExists(string roleName) { if (_App == null) { return(false); } return(RoleSrv.GetByName(roleName, _App.AppID) != null); }
public override string[] GetUsersInRole(string roleName) { if (_App == null) { return(null); } role mRole = RoleSrv.GetByName(roleName, _App.AppID); if (mRole == null) { return(null); } return((from u in mRole.Users select u.username).ToArray()); }
public override void CreateRole(string roleName) { if (_App == null) { return; } role mRole = RoleSrv.GetByName(roleName, _App.AppID); if (mRole == null) { mRole = new role(); mRole.AppID = _App.AppID; mRole.name = roleName; RoleSrv.CreateNew(mRole); RoleSrv.CommitChanges(); } }
public override bool DeleteRole(string roleName, bool throwOnPopulatedRole) { if (_App == null) { return(false); } role mRole = RoleSrv.GetByName(roleName, _App.AppID); if (mRole == null) { return(false); } try { RoleSrv.Delete(mRole); RoleSrv.CommitChanges(); return(true); } catch (Exception ex) { throw ex; } }