Ejemplo n.º 1
0
        public bool IsInRole(string permission)
        {
            string[] permissions;

            if (RolesConfig.GetPermissions(group, out permissions))
            {
                foreach (string permision in permissions)
                {
                    if (permision.Equals(permission))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 2
0
        public CustomPrincipal(WindowsIdentity winIdentity)
        {
            this.identity = winIdentity;

            /// define list of roles based on Windows groups (roles)
            foreach (IdentityReference group in this.identity.Groups)
            {
                SecurityIdentifier sid = (SecurityIdentifier)group.Translate(typeof(SecurityIdentifier));
                var    name            = sid.Translate(typeof(NTAccount));
                string groupName       = Formatter.ParseName(name.ToString());                  /// return name of the Windows group

                if (!roles.ContainsKey(groupName))
                {
                    roles.Add(groupName, RolesConfig.GetPermissions(groupName));
                }
            }
        }