/// <summary> /// Retrieves the Central Access Rules for the Central Policy /// </summary> /// <param name="capId">Unique Identifier for the Central Policy</param> /// <returns>A Dictionary of CAR names and the Central Access Rule object</returns> public Dictionary <string, CentralAccessRule> FetchCentralAccessRules(SecurityIdentifier capId) { Dictionary <string, CentralAccessRule> carInfo = null; if (CapCount == 0 || !availableCaps.Contains(capId)) { return(null); } using (var CapContainer = new DirectoryEntry("LDAP://" + capContainerDN)) { foreach (DirectoryEntry capEntry in CapContainer.Children) { var entryId = capEntry.Properties["msAuthz-CentralAccessPolicyID"].Value; if (entryId == null) { continue; } byte[] rawCapId = entryId as byte[]; if (rawCapId == null) { continue; } var entrySid = new SecurityIdentifier(rawCapId, 0); if (capId == entrySid) { PropertyValueCollection CARs = capEntry.Properties["msAuthz-MemberRulesInCentralAccessPolicy"]; carInfo = new Dictionary <string, CentralAccessRule>(CARs.Count); foreach (string carDN in CARs) { CentralAccessRule CAR = new CentralAccessRule(carDN); carInfo.Add(CAR.Name, CAR); } } } } return(carInfo); }
/// <summary> /// Retrieves the Central Access Rules for the Central Policy /// </summary> /// <param name="capId">Unique Identifier for the Central Policy</param> /// <returns>A Dictionary of CAR names and the Central Access Rule object</returns> public Dictionary<string, CentralAccessRule> FetchCentralAccessRules(SecurityIdentifier capId) { Dictionary<string, CentralAccessRule> carInfo = null; if (CapCount == 0 || !availableCaps.Contains(capId)) { return null; } using (var CapContainer = new DirectoryEntry("LDAP://" + capContainerDN)) { foreach (DirectoryEntry capEntry in CapContainer.Children) { var entryId = capEntry.Properties["msAuthz-CentralAccessPolicyID"].Value; if (entryId == null) { continue; } byte[] rawCapId = entryId as byte[]; if (rawCapId == null) { continue; } var entrySid = new SecurityIdentifier(rawCapId, 0); if (capId == entrySid) { PropertyValueCollection CARs = capEntry.Properties["msAuthz-MemberRulesInCentralAccessPolicy"]; carInfo = new Dictionary<string, CentralAccessRule>(CARs.Count); foreach (string carDN in CARs) { CentralAccessRule CAR = new CentralAccessRule(carDN); carInfo.Add(CAR.Name, CAR); } } } } return carInfo; }