internal void AddOptional(AttributeSchema a) { _may.Add(a); }
internal void AddMandatory(AttributeSchema a) { _must.Add(a); }
public override ReadOnlyCollection <object> GetValuesAsLanguageType(SearchResultEntry se, string attrName) { AttributeSchema aSchema = this.GetAttribute(attrName); if (aSchema == null) { throw new ApplicationException("Unknown attribute " + attrName); } List <object> results = new List <object>(); switch (attrName.ToLowerInvariant()) { case "pwdlastset": case "accountexpires": case "badpasswordtime": case "lockouttime": case "lastlogontimestamp": case "lastlogon": { foreach (string s in se.Attributes[attrName].GetValues(typeof(string))) { Int64 n = Int64.Parse(s); if (n == 0 || n == 0x7FFFFFFFFFFFFFFF) { results.Add("NEVER"); } else { try { results.Add(DateTime.FromFileTimeUtc(n)); } catch (Exception ex) { logger.Warn("Couldn't convert {0} to DateTime: {1}", s, ex.Message); } } } } break; case "objectguid": { foreach (byte[] bytes in se.Attributes[attrName].GetValues(typeof(byte[]))) { results.Add(new Guid(bytes)); } } break; default: switch (aSchema.LangType) { case AttrLangType.NtSID: { foreach (byte[] bytes in se.Attributes[attrName].GetValues(typeof(byte[]))) { results.Add(new SecurityIdentifier(bytes, 0)); } } break; case AttrLangType.NtSecurityDescriptor: { foreach (byte[] bytes in se.Attributes[attrName].GetValues(typeof(byte[]))) { results.Add(new RawSecurityDescriptor(bytes, 0)); } } break; default: return(base.GetValuesAsLanguageType(se, attrName)); } break; } return(new System.Collections.ObjectModel.ReadOnlyCollection <object>(results)); }
public virtual ReadOnlyCollection <object> GetValuesAsLanguageType(SearchResultEntry se, string attrName) { AttributeSchema aSchema = this.GetAttribute(attrName); if (aSchema == null) { throw new ApplicationException("Unknown attribute " + attrName); } List <object> results = new List <object>(); if (se.Attributes.Contains(attrName)) { switch (aSchema.LangType) { case AttrLangType.GeneralizedTime: foreach (string s in se.Attributes[attrName].GetValues(typeof(string))) { // 20090203065703.0Z string t = s.Replace(".0Z", ""); DateTime dt = DateTime.ParseExact(t, new string[] { "yyyyMMddHHmmss" }, null, System.Globalization.DateTimeStyles.AssumeUniversal); results.Add(dt); } break; case AttrLangType.Boolean: { foreach (string s in se.Attributes[attrName].GetValues(typeof(string))) { results.Add(bool.Parse(s)); } } break; case AttrLangType.Int32: { foreach (string s in se.Attributes[attrName].GetValues(typeof(string))) { results.Add(Int32.Parse(s)); } } break; case AttrLangType.Int64: { foreach (string s in se.Attributes[attrName].GetValues(typeof(string))) { results.Add(Int64.Parse(s)); } } break; case AttrLangType.OctetString: results.AddRange(se.Attributes[attrName].GetValues(typeof(byte[]))); break; case AttrLangType.DirectoryString: case AttrLangType.CaseInsensitiveString: case AttrLangType.DN: default: results.AddRange(se.Attributes[attrName].GetValues(typeof(string))); break; } } return(new System.Collections.ObjectModel.ReadOnlyCollection <object>(results)); }