public static JObject AssessPrivRights(JToken privRights) { JObject jankyDb = JankyDb.Instance; JArray intPrivRights = (JArray)jankyDb["privRights"]; // create an object to put the results in JObject assessedPrivRights = new JObject(); //set an intentionally non-matchy domainSid value unless we doing online checks. string domainSid = "X"; if (GlobalVar.OnlineChecks) { domainSid = LDAPstuff.GetDomainSid(); } //iterate over the entries foreach (JProperty privRight in privRights.Children <JProperty>()) { foreach (JToken intPrivRight in intPrivRights) { // if the priv is interesting if ((string)intPrivRight["privRight"] == privRight.Name) { bool privIsInteresting = false; string privRightDesc = GetOsPrivDescription(privRight.Name); if (privRightDesc.EndsWith("I")) { privRightDesc = privRightDesc.Trim('I'); privIsInteresting = true; } //create a jobj to put the trustees into JObject trustees = new JObject(); //then for each trustee it's granted to if (privRight.Value is JArray) { foreach (JToken trusteeJToken in privRight.Value) { int interestLevel = 3; string trustee = trusteeJToken.ToString(); string trusteeClean = trustee.Trim('*'); string trusteeHighOrLow = Sid.GetWKSidHighOrLow(trusteeClean); if ((trusteeHighOrLow == "Low") && privIsInteresting) { interestLevel = 10; } if (trusteeHighOrLow == "High") { interestLevel = 0; } if (interestLevel >= GlobalVar.IntLevelToShow) { try { trustees.Add(GetTrustee(trusteeClean)); } catch (Exception e) { Utility.Output.DebugWrite(e.ToString()); } } } } else { int interestLevel = 2; string trusteeClean = privRight.Value.ToString().Trim('*'); string trusteeHighOrLow = Sid.GetWKSidHighOrLow(trusteeClean); if ((trusteeHighOrLow == "Low") && privIsInteresting) { interestLevel = 10; } if (trusteeHighOrLow == "High") { interestLevel = 0; } if (interestLevel >= GlobalVar.IntLevelToShow) { trustees.Add(GetTrustee(trusteeClean)); } } // add the results to our jobj of trustees if they are interesting enough. if (trustees.HasValues) { trustees.Add("Description", privRightDesc); assessedPrivRights.Add(new JProperty(privRight.Name, trustees)); } } } } return(assessedPrivRights); }