Пример #1
0
        /// <summary>
        /// Obtiene la informacion de un usuario y junto a sus roles
        /// </summary>
        /// <param name="userName">Nombre de usuario</param>
        /// <param name="providerName">Nombre del proveedor de membership</param>
        /// <returns></returns>
        public static User GetUserAnRoles(String userName, string providerName)
        {
            User    wUser     = FwkMembership.GetUser(userName, providerName);
            RolList userRoles = FwkMembership.GetRolesForUser(userName, providerName);

            wUser.Roles = userRoles.GetArrayNames();
            return(wUser);
        }
Пример #2
0
        /// <summary>
        /// Obtiene una lista de usuarios con sus detalles pertenecientes a un determinado rol
        /// </summary>
        /// <param name="roleName">Nombre del rol</param>
        /// <param name="providerName">Nombre del proveedor de membership</param>
        /// <returns>lista de <see cref="User"/> </returns>
        public static List <User> GetUsersDetailedInRole(String roleName, string providerName)
        {
            User wUserByApp;
            SqlMembershipProvider wProvider  = GetSqlMembershipProvider(providerName);
            List <User>           wUsersList = new List <User>();

            try
            {
                foreach (string userName in Roles.Providers[wProvider.Name].GetUsersInRole(roleName))
                {
                    wUserByApp = FwkMembership.GetUser(userName, providerName);
                    wUsersList.Add(wUserByApp);
                }
            }
            catch (Exception ex)
            {
                Fwk.Exceptions.TechnicalException te = new TechnicalException(Fwk.Security.Properties.Resource.MembershipSecurityGenericError, ex);
                ExceptionHelper.SetTechnicalException <FwkMembership>(te);
                te.ErrorId = "4000";
                throw te;
            }

            return(wUsersList);
        }