コード例 #1
0
 /// <summary>
 /// Gets a value indicating whether the specified user is in the specified role for the configured applicationName.
 /// </summary>
 /// <param name="user">The user to check for</param>
 /// <param name="roleName">The role to check for</param>
 /// <returns><b>true</b> if user is in role, <b>false</b> otherwise</returns>
 public bool IsUserInRole(User user, string roleName)
 {
     if (user == null)
     {
         return(false);
     }
     return(RoleDataSource.IsUserInRole(user.UserId, roleName));
 }
コード例 #2
0
        /// <summary>
        /// Gets a value indicating whether the specified user is in the specified role for the configured applicationName.
        /// </summary>
        /// <param name="username">The name of the user to check for</param>
        /// <param name="roleName">The role to check for</param>
        /// <returns><b>true</b> if user is in role, <b>false</b> otherwise</returns>
        public override bool IsUserInRole(string username, string roleName)
        {
            User user = UserDataSource.LoadForUserName(username);

            if (user == null)
            {
                return(false);
            }
            return(RoleDataSource.IsUserInRole(user.UserId, roleName));
        }
コード例 #3
0
        /// <summary>
        /// Removes a role from the data source for the configured application Name
        /// </summary>
        /// <param name="roleName">The role to delete</param>
        /// <param name="throwOnPopulatedRole">If true, throw an exception if roleName has one or more members and do not delete roleName.</param>
        /// <returns><b>true</b> if role is deleted <b>false</b> otherwise</returns>
        public override bool DeleteRole(string roleName, bool throwOnPopulatedRole)
        {
            Role role = RoleDataSource.LoadForRolename(roleName);

            if (role == null)
            {
                return(false);
            }
            return(role.Delete());
        }
コード例 #4
0
ファイル: RoleCache.cs プロジェクト: phongdevelopers/my-phong
        private void InternalReload()
        {
            roleIdLookup = new Dictionary <string, int>();
            RoleCollection allRoles = RoleDataSource.LoadAll();

            foreach (Role role in allRoles)
            {
                roleIdLookup[role.LoweredName] = role.RoleId;
            }
        }
コード例 #5
0
        /// <summary>
        /// Gets a list of all the roles for the configured applicationName.
        /// </summary>
        /// <returns>A string array containing the names of all the roles stored in the data source for the configured applicationName.</returns>
        public override string[] GetAllRoles()
        {
            RoleCollection roleCollection = RoleDataSource.LoadAll();

            string[] allRoles = new string[roleCollection.Count];
            for (int index = 0; index < roleCollection.Count; index++)
            {
                allRoles[index] = roleCollection[index].Name;
            }
            return(allRoles);
        }
コード例 #6
0
 /// <summary>
 /// Makes sure that the default roles expected for a store are available
 /// in the database
 /// </summary>
 internal static void EnsureDefaultRoles()
 {
     string[] defaultRoles = Role.AllAdminRoles;
     //make sure the admin role exists
     foreach (string roleName in defaultRoles)
     {
         Role role = RoleDataSource.LoadForRolename(roleName);
         if (role == null)
         {
             role      = new Role();
             role.Name = roleName;
             role.Save();
         }
     }
 }
コード例 #7
0
        /// <summary>
        /// Gets a list of the roles that a specified user is in for the configured applicationName.
        /// </summary>
        /// <param name="username">The user to return a list of roles for.</param>
        /// <returns>A string array containing the names of all the roles that the specified user is in for the configured applicationName.</returns>
        public override string[] GetRolesForUser(string username)
        {
            string[] userRoles = new string[0];
            User     user      = UserDataSource.LoadForUserName(username);

            if (user != null)
            {
                RoleCollection roles = RoleDataSource.LoadForUser(user.UserId);
                if (roles.Count > 0)
                {
                    userRoles = new string[roles.Count];
                    for (int i = 0; i < roles.Count; i++)
                    {
                        userRoles[i] = roles[i].Name;
                    }
                }
            }
            return(userRoles);
        }
コード例 #8
0
ファイル: Group.cs プロジェクト: phongdevelopers/my-phong
 /// <summary>
 /// Determines whether this group has the given role assigned.
 /// </summary>
 /// <param name="name">The name of the role to check.</param>
 /// <returns>True if the group has the given role; false otherwise.</returns>
 public bool IsInRole(string name)
 {
     return(RoleDataSource.IsGroupInRole(this.GroupId, name));
 }
コード例 #9
0
 /// <summary>
 /// Determines whether a user is in the given role.
 /// </summary>
 /// <param name="roleId">The unique ID of the role to check.</param>
 /// <returns>True if the user is in the given role; false otherwise.</returns>
 public bool IsInRole(int roleId)
 {
     return(RoleDataSource.IsUserInRole(this.UserId, roleId));
 }
コード例 #10
0
 /// <summary>
 /// Determines whether a user is in the given role.
 /// </summary>
 /// <param name="name">The name of the role to check.</param>
 /// <returns>True if the user is in the given role; false otherwise.</returns>
 public bool IsInRole(string name)
 {
     return(RoleDataSource.IsUserInRole(this.UserId, name));
 }
コード例 #11
0
 public static Role Load(Int32 roleId)
 {
     return(RoleDataSource.Load(roleId, true));
 }
コード例 #12
0
 public static RoleCollection LoadForGroup(Int32 groupId, int maximumRows, int startRowIndex)
 {
     return(RoleDataSource.LoadForGroup(groupId, maximumRows, startRowIndex, string.Empty));
 }
コード例 #13
0
 public static RoleCollection LoadForGroup(Int32 groupId, string sortExpression)
 {
     return(RoleDataSource.LoadForGroup(groupId, 0, 0, sortExpression));
 }
コード例 #14
0
 public static RoleCollection LoadForGroup(Int32 groupId)
 {
     return(RoleDataSource.LoadForGroup(groupId, 0, 0, string.Empty));
 }
コード例 #15
0
        /// <summary>
        /// Loads a role instance given the name.
        /// </summary>
        /// <param name="name">The case-insensitive role name.</param>
        /// <returns>The role instance, or null if the role is not found.</returns>
        public static Role LoadForRolename(string name)
        {
            int roleId = RoleDataSource.GetIdByName(name);

            return(RoleDataSource.Load(roleId));
        }
コード例 #16
0
 public static RoleCollection LoadAll(int maximumRows, int startRowIndex)
 {
     return(RoleDataSource.LoadAll(maximumRows, startRowIndex, string.Empty));
 }
コード例 #17
0
 public static RoleCollection LoadAll(string sortExpression)
 {
     return(RoleDataSource.LoadAll(0, 0, sortExpression));
 }
コード例 #18
0
 public static RoleCollection LoadAll()
 {
     return(RoleDataSource.LoadAll(0, 0, string.Empty));
 }
コード例 #19
0
 /// <summary>
 /// Gets a value indicating whether the specified role name already exists in the role data source for the configured applicationName.
 /// </summary>
 /// <param name="roleName">The role name to check</param>
 /// <returns><b>true</b> if role already exists, <b>false</b> otherwise</returns>
 public override bool RoleExists(string roleName)
 {
     return(RoleDataSource.GetIdByName(roleName) > 0);
 }