private DateTime GetLastHighWatermark(WatermarkKeyedCollection importState, string key) { if (importState == null) { throw new WarningNoWatermarkException("No watermark was available to perform a delta import"); } if (!importState.Contains(key)) { throw new WarningNoWatermarkException("No watermark was available to perform a delta import for the group object type"); } string value = importState[key].Value; long ticks = long.Parse(value); return(new DateTime(ticks)); }
private IAsyncEnumerable <IUser> GetUserEnumerable(bool inDelta, WatermarkKeyedCollection importState, IOktaClient client, ImportContext context) { IAsyncEnumerable <IUser> users; if (inDelta) { if (importState == null) { throw new WarningNoWatermarkException("No watermark was available to perform a delta import"); } if (!importState.Contains("users")) { throw new WarningNoWatermarkException("No watermark was available to perform a delta import for the user object type"); } string value = importState["users"].Value; long ticks = long.Parse(value); DateTime dt = new DateTime(ticks); string filter = $"(lastUpdated gt \"{dt.ToSmartString()}Z\")"; if (context.ConfigParameters[ConfigParameterNames.UserDeprovisioningAction].Value == "Delete") { filter += " and(status eq \"LOCKED_OUT\" or status eq \"RECOVERY\" or status eq \"STAGED\" or status eq \"PROVISIONED\" or status eq \"ACTIVE\" or status eq \"PASSWORD_EXPIRED\" or status eq \"DEPROVISIONED\" or status eq \"SUSPENDED\")"; } users = client.Users.ListUsers(null, null, OktaMAConfigSection.Configuration.UserListPageSize, filter); } else { string filter = null; if (context.ConfigParameters[ConfigParameterNames.UserDeprovisioningAction].Value == "Delete") { filter = "(status eq \"LOCKED_OUT\" or status eq \"RECOVERY\" or status eq \"STAGED\" or status eq \"PROVISIONED\" or status eq \"ACTIVE\" or status eq \"PASSWORD_EXPIRED\" or status eq \"DEPROVISIONED\" or status eq \"SUSPENDED\")"; } users = client.Users.ListUsers(null, null, OktaMAConfigSection.Configuration.UserListPageSize, filter); } return(users); }
private IAsyncEnumerable <IGroup> GetGroupEnumerable(bool inDelta, KeyedCollection <string, ConfigParameter> configParameters, WatermarkKeyedCollection importState, IOktaClient client) { List <string> filterConditions = new List <string>(); if (configParameters[ConfigParameterNames.IncludeBuiltInGroups].Value == "1") { filterConditions.Add("(type eq \"BUILT_IN\")"); } if (configParameters[ConfigParameterNames.IncludeAppGroups].Value == "1") { filterConditions.Add("(type eq \"APP_GROUP\")"); } filterConditions.Add("(type eq \"OKTA_GROUP\")"); string filter = string.Join(" OR ", filterConditions); if (inDelta) { this.lastGroupUpdateHighWatermark = this.GetLastHighWatermarkGroup(importState); this.lastGroupMemberUpdateHighWatermark = this.GetLastHighWatermarkGroupMember(importState); filter = $"({filter}) AND (lastUpdated gt \"{this.lastGroupUpdateHighWatermark.ToSmartString()}Z\" or lastMembershipUpdated gt \"{this.lastGroupMemberUpdateHighWatermark.ToSmartString()}Z\")"; } return(client.Groups.ListGroups(null, filter, null, OktaMAConfigSection.Configuration.GroupListPageSize)); }
private DateTime GetLastHighWatermarkGroupMember(WatermarkKeyedCollection importState) { return(this.GetLastHighWatermark(importState, GroupMemberUpdateKey)); }