Esempio n. 1
0
 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();
 }
Esempio n. 2
0
 public override bool RoleExists(string roleName)
 {
     if (_App == null)
     {
         return(false);
     }
     return(RoleSrv.GetByName(roleName, _App.AppID) != null);
 }
Esempio n. 3
0
        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());
        }
Esempio n. 4
0
        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();
            }
        }
Esempio n. 5
0
        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;
            }
        }