Exemplo n.º 1
0
 public static int Add(string containerKey, string role, int principalId, UserRoleTypeEnum type)
 {
     if (type == UserRoleTypeEnum.SingleValue)
     {
         DBUserRole.DeleteByRole(containerKey, role);
     }
     return DBUserRole.Add(principalId, containerKey, role);
 }
Exemplo n.º 2
0
        public Task <IdentityResult> Create(User user, string password, UserRoleTypeEnum role)
        {
            //add claims & roles
            var ir = _userManager.CreateAsync(user, password);

            ir = _userManager.AddToRoleAsync(user, role.ToString());
            var newClaim = new Claim(role.ToString(), role.ToString(), ClaimValueTypes.String);

            ir = _userManager.AddClaimAsync(user, newClaim);
            return(ir);
        }
Exemplo n.º 3
0
 public Role(EnterpriseManagementGroup mg, UserRoleTypeEnum roleType)
 {
     if (mg == null)
     {
         throw new ArgumentNullException("mg");
     }
     this.existing        = false;
     this.managementGroup = mg;
     this.userRole        = new Microsoft.EnterpriseManagement.Security.UserRole();
     this.userRole.Name   = string.Format(CultureInfo.InvariantCulture, "{0}.{1}", new object[] { "UserRole", Guid.NewGuid() });
     this.profile         = this.GetProfile(mg, roleType.ToString());
     this.scope           = new UserRoleScope();
 }