/// <summary> /// IsBinaryAttribute method implmentation /// </summary> internal static bool IsBinaryAttribute(string domainname, string username, string password, string attributename) { try { using (Domain domain = ADDSUtils.GetRootDomain(domainname, username, password)) { using (Forest forest = ADDSUtils.GetForest(domain.Name, username, password)) { ActiveDirectorySchemaProperty property = forest.Schema.FindProperty(attributename); if (property != null) { if (property.Syntax.Equals(ActiveDirectorySyntax.OctetString)) { return(true); } } } } return(false); } catch (Exception ex) { DataLog.WriteEntry(ex.Message, System.Diagnostics.EventLogEntryType.Error, 5100); return(false); } }
/// <summary> /// LoadForests method implementation /// </summary> public static void LoadForests(string domainname, string account, string password, bool usessl, bool reset = false) { if (reset) { ResetForests(); } if (_isbinded) { return; } try { _usessl = usessl; using (Domain domain = ADDSUtils.GetRootDomain(domainname, account, password)) { using (Forest forest = ADDSUtils.GetForest(domain.Name, account, password)) { Forests.Clear(); ADDSHostForest root = new ADDSHostForest { IsRoot = true, ForestDNS = forest.Name }; Forests.Add(root); foreach (ForestTrustRelationshipInformation trusts in forest.GetAllTrustRelationships()) { ADDSHostForest sub = new ADDSHostForest { IsRoot = false, ForestDNS = trusts.TargetName }; foreach (TopLevelName t in trusts.TopLevelNames) { if (t.Status == TopLevelNameStatus.Enabled) { sub.TopLevelNames.Add(t.Name); } } Forests.Add(sub); } } } _isbinded = true; } catch (Exception ex) { DataLog.WriteEntry(ex.Message, System.Diagnostics.EventLogEntryType.Error, 5100); _isbinded = false; } }