public CustomPrincipal(WindowsIdentity winIndentity) { this.identity = winIndentity; 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()); if (groupName == "Reader" || groupName == "AlarmGenerator" || groupName == "AlarmAdmin") { roles.Add(groupName, RolesConfig.GetPermissions(groupName)); } } }
private Dictionary <string, string[]> roles = new Dictionary <string, string[]>(); //uloge sa permisijama se spajaju public CustomPrincipal(WindowsIdentity winIdentity) //ovde je problem negde { /// define list of roles based on custom roles string[] rolesTypes = Enum.GetNames(typeof(Role)); foreach (IdentityReference group in winIdentity.Groups) { SecurityIdentifier sid = (SecurityIdentifier)group.Translate(typeof(SecurityIdentifier)); var name = sid.Translate(typeof(NTAccount)); string groupName = Formatter.ParseName(name.ToString()); foreach (string g in Enum.GetNames(typeof(Role))) { if (g.ToString().Equals(groupName)) { if (!roles.ContainsKey(groupName)) { roles.Add(groupName, RolesConfig.GetPermissions(g.ToString())); break; } } } } }