private bool ShouldFilterDelta(Beta.Group group) { string filter = this.context.ConfigParameters[ConfigParameterNames.FilterQuery].Value; if (!string.IsNullOrWhiteSpace(filter)) { if (group.MailNickname == null || !group.MailNickname.StartsWith(filter, StringComparison.OrdinalIgnoreCase)) { logger.Trace($"Filtering group {group.Id} with nickname {group.MailNickname}"); return(true); } } if (group.AdditionalData == null) { logger.Trace($"Filtering non-team group {group.Id} with nickname {group.MailNickname}"); return(true); } if (!this.context.InDelta && group.AdditionalData.ContainsKey("@removed")) { logger.Trace($"Filtering deleted group {group.Id} with nickname {group.MailNickname}"); return(true); } if (!group.AdditionalData.ContainsKey("resourceProvisioningOptions")) { logger.Trace($"Filtering non-team group {group.Id} with nickname {group.MailNickname}"); return(true); } var rpo = group.AdditionalData["resourceProvisioningOptions"] as JArray; if (!rpo.Values().Any(t => string.Equals(t.Value <string>(), "team", StringComparison.OrdinalIgnoreCase))) { logger.Trace($"Filtering non-team group {group.Id} with nickname {group.MailNickname}"); return(true); } return(false); }
private CSEntryChange GroupToCSEntryChange(Beta.Group group, SchemaType schemaType) { CSEntryChange c = CSEntryChange.Create(); c.ObjectType = "group"; c.AnchorAttributes.Add(AnchorAttribute.Create("id", group.Id)); c.DN = group.Id; bool isRemoved = group.AdditionalData?.ContainsKey("@removed") ?? false; logger.Trace(JsonConvert.SerializeObject(group)); if (this.context.InDelta) { if (isRemoved) { c.ObjectModificationType = ObjectModificationType.Delete; return(c); } else { c.ObjectModificationType = ObjectModificationType.Replace; } } else { if (isRemoved) { return(null); } c.ObjectModificationType = ObjectModificationType.Add; } foreach (SchemaAttribute type in schemaType.Attributes) { switch (type.Name) { case "displayName": if (!string.IsNullOrWhiteSpace(group.DisplayName)) { c.AttributeChanges.Add(AttributeChange.CreateAttributeAdd(type.Name, group.DisplayName)); } break; case "description": if (!string.IsNullOrWhiteSpace(group.Description)) { c.AttributeChanges.Add(AttributeChange.CreateAttributeAdd(type.Name, group.Description)); } break; case "id": c.AttributeChanges.Add(AttributeChange.CreateAttributeAdd(type.Name, group.Id)); break; case "mailNickname": if (!string.IsNullOrWhiteSpace(group.MailNickname)) { c.AttributeChanges.Add(AttributeChange.CreateAttributeAdd(type.Name, group.MailNickname)); } break; case "visibility": if (!string.IsNullOrWhiteSpace(group.Visibility)) { c.AttributeChanges.Add(AttributeChange.CreateAttributeAdd(type.Name, group.Visibility)); } break; } } return(c); }