/// <summary> /// Reads specified types of certificates from the current container. /// </summary> /// <param name="certTypes">Specifies a collection of certificate types to read.</param> protected void ReadChildren(DsCertificateType[] certTypes) { var entries = new List <DirectoryEntry>(); // handle NTAuth container, because it doesn't have children. if (ContainerType == DsContainerType.NTAuth) { foreach (DirectoryEntry child in BaseEntry.Parent.Children) { entries.Add(child); } } else { foreach (DirectoryEntry child in BaseEntry.Children) { entries.Add(child); } } foreach (DirectoryEntry child in entries) { // read only entries of specified DS object class if (!DsObjectClasses.Contains(child.SchemaClassName)) { continue; } String key = ContainerType == DsContainerType.NTAuth ? "NTAuth" : child.Properties["cn"][0].ToString(); foreach (DsCertificateType type in certTypes) { List <DsCertificateEntry> items = readCertsFromDsAttribute(child, key, type); // add to global list foreach (DsCertificateEntry item in items) { _list.Add(item); } // add to child-specific list. if (DsList.ContainsKey(key)) { DsList[key].AddRange(items); } else { DsList.Add(key, items); } } } }
/// <summary> /// Adds new certificate entry to internal list. /// </summary> /// <param name="entry">Certificate entry to add.</param> /// <exception cref="ArgumentNullException"> /// <strong>entry</strong> parameter is null. /// </exception> /// <returns> /// <strong>True</strong> if this is a new certificate and no duplicates exist. If certificate entry /// already exists in internal list, method returns <strong>False</strong>. /// </returns> protected Boolean AddCertificateEntry(DsCertificateEntry entry) { if (entry == null) { throw new ArgumentNullException(nameof(entry)); } if (!_list.Add(entry)) { return(false); } // mutually exclusive. entry cannot be added and removed at the same time. _toBeAdded.Add(entry.Name); _toBeRemoved.Remove(entry.Name); if (DsList.ContainsKey(entry.Name)) { DsList[entry.Name].Add(entry); } else { DsList.Add(entry.Name, new List <DsCertificateEntry>()); DsList[entry.Name].Add(entry); } return(IsModified = true); }