public ActiveDirectorySyntax GetAttributeSyntax(string name, out bool isBad) { ActiveDirectorySyntax ret = ActiveDirectorySyntax.CaseIgnoreString; bool syntaxfromcache = true; bool notfound = true; bool incache = false; isBad = false; AttributeSchema attribute = null;; if (name.Contains(";")) { name = name.Substring(0, name.IndexOf(";")); } try { if (ForestBase.AttributeCache.ContainsKey(name)) { attribute = ForestBase.AttributeCache[name]; ret = attribute.Syntax; syntaxfromcache = attribute.SyntaxFromCache; isBad = attribute.UnkownSyntax; notfound = false; } if ((syntaxfromcache) && (ret == ActiveDirectorySyntax.OctetString)) { incache = AttributeIsInCache(ForestBase.ForestName, name, out ret, out isBad); if ((incache) || (isBad)) { attribute.UpdateSyntax(ret, isBad); return(ret); } else { ActiveDirectorySyntax temp = SyntaxFromLiveSchema(name); attribute.UpdateSyntax(temp); ret = temp; AddAttributeToCache(ForestBase.ForestName, name, ret, false); return(ret); } } if (notfound) { } } catch (Exception ex) { ex.ToDummy(); } return(ret); }
private void LoadAttributesFromCache() { ForestBase.AttributeCache = new Dictionary <string, AttributeSchema>(StringComparer.InvariantCultureIgnoreCase) { }; ActiveDirectorySyntax adsyntax; string check; foreach (XElement attribnode in ForestBase.CurrentAttributesNode.Elements()) { string name = attribnode.Name.LocalName; adsyntax = ActiveDirectorySyntax.OctetString; string syntax = attribnode.Value; check = "0"; XAttribute acheck = attribnode.Attributes("checked").FirstOrDefault(); if (acheck != null) { check = acheck.Value; } bool ischecked = check.ToBool(); check = "0"; XAttribute aconstructed = attribnode.Attributes("constructed").FirstOrDefault(); if (aconstructed != null) { check = aconstructed.Value; } bool isconstructed = check.ToBool(); check = "0"; XAttribute alinked = attribnode.Attributes("linked").FirstOrDefault(); if (alinked != null) { check = alinked.Value; } long linkid = 0; long.TryParse(check, out linkid); bool isbad = false; if (syntax == "Unknown") { isbad = true; } else { adsyntax = StringSyntaxToADSynatx(syntax); } AttributeSchema aschema = new AttributeSchema(name, adsyntax, isconstructed, linkid) { Checked = ischecked, UnkownSyntax = isbad }; ForestBase.AttributeCache.AddSafe(name, aschema); } }