Esempio n. 1
0
        public override void CreateRole(string roleName)
        {
            SecUtility.CheckParameter(ref roleName, true, true, true, 256, "roleName");
            try
            {
                using (var session = new MongoSession(_connectionString))
                {
                    var roles = from r in session.Roles
                                where r.RoleName == roleName
                                select r;

                    if (roles.Any())
                    {
                        throw new ProviderException(StringResources.GetString(StringResources.Provider_role_already_exists, roleName));
                    }


                    var role = new MembershipRole
                    {
                        RoleName        = roleName,
                        LoweredRoleName = roleName.ToLowerInvariant()
                    };

                    session.Add(role);
                }
            }
            catch
            {
                throw;
            }
        }
Esempio n. 2
0
        public static MembershipPermission CreatePermission(string name)
        {
            MembershipPermission permission = _session.Permissions.FirstOrDefault(x => x.Name == name);

            if (permission == null)
            {
                permission = new MembershipPermission
                {
                    Name = name
                };

                _session.Add <MembershipPermission>(permission);
            }

            return(permission);
        }