Exemplo n.º 1
0
        public static ADAttributes BuildAttributes(ResultPropertyCollection properties)
        {
            ADAttributes          attributes = new ADAttributes();
            IDictionaryEnumerator enumerator = properties.GetEnumerator();

            attributes.Uuid = new Guid((byte[])properties[OBJECT_GUID_ATTRIBUTE][0]).ToString();

            if (properties.Contains(OBJECT_DN_ATTRIBUTE) && properties[OBJECT_DN_ATTRIBUTE].Count > 0 && !String.IsNullOrEmpty(properties[OBJECT_DN_ATTRIBUTE][0].ToString()))
            {
                attributes.DistinguishedName = properties[OBJECT_DN_ATTRIBUTE][0].ToString();
            }

            while (enumerator.MoveNext())
            {
                int          nrOfAttributes = ((ResultPropertyValueCollection)enumerator.Value).Count;
                IADAttribute attribute      = createIADAttribute(nrOfAttributes, (DictionaryEntry)enumerator.Current, OBJECT_GUID_ATTRIBUTE);

                if (attribute != null)
                {
                    attributes.Add(attribute);
                }
            }

            return(attributes);
        }
Exemplo n.º 2
0
 public void Add(IADAttribute attribute)
 {
     if (!Contains(attribute.Name))
     {
         Attributes.Add(attribute.Name, attribute);
     }
 }
Exemplo n.º 3
0
        private static string getSingleAttribute(ADEvent anEvent, String name)
        {
            IADAttribute attribute = anEvent.ADAttributes.GetField(name);

            if (attribute is ADSingleValueAttribute)
            {
                return(((ADSingleValueAttribute)attribute).Value);
            }
            else if (attribute is ADMultiValueAttribute)
            {
                var values = ((ADMultiValueAttribute)attribute).Values;

                if (values.Count > 0)
                {
                    // someone is using a REG_MULTI_SZ field as a key for a single value element - so we just pick the first record
                    return(values[0]);
                }
            }

            return(null);
        }