public ADEvent Enrich(ADEvent poorEvent) { ObjectType affectedObjectType = poorEvent.AffectedObjectType; OperationType operationType = poorEvent.OperationType; DateTime timeOcurred = poorEvent.TimeOcurred; long id = poorEvent.Id; ADAttributes attributes = null; if (poorEvent.OperationType.Equals(OperationType.Remove)) { attributes = new ADAttributes(); attributes.Uuid = poorEvent.ADAttributes.Uuid; attributes.DistinguishedName = poorEvent.ADAttributes.DistinguishedName; return(new ADEvent(id, operationType, affectedObjectType, attributes, timeOcurred, null)); } // make an ldap call and get full object attributes = attributeLoader.Load(poorEvent.ADAttributes.DistinguishedName); if (string.IsNullOrEmpty(attributes.Uuid)) { // if the object is outside the hiearchy, the UUID is nulled, so for updates // we need to ensure we get the UUID copied back, so we can safely delete the object attributes.Uuid = poorEvent.ADAttributes.Uuid; } string parentOUUUID = adUtils.GetOUParent(poorEvent)?.ADAttributes?.Uuid; return(new ADEvent(id, operationType, affectedObjectType, attributes, timeOcurred, parentOUUUID)); }
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); }
private ADAttributes Blocked(String cn) { ADAttributes attr = new ADAttributes(); attr.DistinguishedName = cn; attr.Attributes[AppConfiguration.OUAttributeFiltered] = new ADSingleValueAttribute("OUAttributeFiltered", Constants.BLOCKED); return(attr); }
private static ADEvent EventOnObjectUpdate(ADAttributes attributes, bool isUser) { if (!isUser) { return(new ADEvent(0, OperationType.Update, ObjectType.OU, attributes, DateTime.Now, null)); } return(new ADEvent(0, OperationType.Update, ObjectType.User, attributes, DateTime.Now, null)); }
private static ADEvent EventOnObjectCreated(ADAttributes attributes, bool isUser) { if (attributes.Contains("whencreated") && (!attributes.Contains("useraccountcontrol"))) { return(new ADEvent(0, OperationType.Create, ObjectType.OU, attributes, DateTime.Now, null)); } else if (attributes.Contains("whencreated") && attributes.Contains("objectclass") && isUser) { return(new ADEvent(0, OperationType.Create, ObjectType.User, attributes, DateTime.Now, null)); } return(null); }
public static ADEvent Build(SearchResult searchResult) { bool isUser = IsUser(searchResult); ADAttributes attributes = AttributesBuilder.BuildAttributes(searchResult.Properties); ADEvent deletedObject = EventOnObjectDeleted(attributes, isUser); if (deletedObject != null) { return(deletedObject); } ADEvent createdObject = EventOnObjectCreated(attributes, isUser); if (createdObject != null) { return(createdObject); } return(EventOnObjectUpdate(attributes, isUser)); }
private static ADEvent EventOnObjectDeleted(ADAttributes attributes, bool isUser) { if (!attributes.Contains(IS_DELETED_ATTRIBUTE)) { return(null); } ADSingleValueAttribute isDeleted = (ADSingleValueAttribute)attributes.GetField(IS_DELETED_ATTRIBUTE); if (isDeleted.Value != null && "true".Equals((string)isDeleted.Value.ToLower())) { if (isUser) { return(new ADEvent(0, OperationType.Remove, ObjectType.User, attributes, DateTime.Now, null)); } else { return(new ADEvent(0, OperationType.Remove, ObjectType.OU, attributes, DateTime.Now, null)); } } return(null); }
public ADEvent(long id, OperationType operationType, ObjectType affectedObjectType, ADAttributes adAttributes, DateTime timeOcurred, string parentOUUUID) { this.Id = id; this.OperationType = operationType; this.AffectedObjectType = affectedObjectType; this.ADAttributes = adAttributes; this.TimeOcurred = timeOcurred; this.ParentOUUUID = parentOUUUID; }