public Task GetObjectImportTask(Schema schema, BlockingCollection <object> collection, CancellationToken cancellationToken) { Task t = new Task(() => { HashSet <string> seenDNs = new HashSet <string>(); foreach (ContactEntry contact in this.config.ContactsService.GetContacts(this.config.Domain)) { if (!string.IsNullOrWhiteSpace(this.config.ContactRegexFilter)) { if (contact.PrimaryEmail != null) { if (!Regex.IsMatch(contact.PrimaryEmail.Address, this.config.ContactRegexFilter, RegexOptions.IgnoreCase)) { continue; } } } string dn = this.GetDNValue(contact); if (dn == null) { Logger.WriteLine($"Contact {contact.SelfUri.Content} had no DN or primary email attribute, ignoring"); continue; } if (!seenDNs.Add(dn)) { Logger.WriteLine($"Ignoring contact {contact.SelfUri.Content} with duplicate dn {dn}"); continue; } collection.Add(ImportProcessor.GetCSEntryChange(contact, schema.Types[SchemaConstants.Contact], this.config)); } }, cancellationToken); t.Start(); return(t); }
private CSEntryChange GetCSEntryForCourse(GoogleCourse course, Microsoft.MetadirectoryServices.Schema schema) { CSEntryChange csentry; if (course.Errors.Count > 0) { csentry = CSEntryChange.Create(); csentry.ObjectType = "course"; csentry.ObjectModificationType = ObjectModificationType.Add; csentry.DN = course.Course.Id; csentry.ErrorCodeImport = MAImportError.ImportErrorCustomContinueRun; csentry.ErrorDetail = course.Errors.FirstOrDefault()?.StackTrace; csentry.ErrorName = course.Errors.FirstOrDefault()?.Message; } else { csentry = ImportProcessor.GetCSEntryChange(course, schema.Types[SchemaConstants.Course], this.config); } return(csentry); }
private CSEntryChange GetCSEntryForGroup(GoogleGroup group, Schema schema) { CSEntryChange csentry; if (group.Errors.Count > 0) { csentry = CSEntryChange.Create(); csentry.ObjectType = "group"; csentry.ObjectModificationType = ObjectModificationType.Add; csentry.DN = group.Group.Email; csentry.ErrorCodeImport = MAImportError.ImportErrorCustomContinueRun; csentry.ErrorDetail = group.Errors.FirstOrDefault()?.StackTrace; csentry.ErrorName = group.Errors.FirstOrDefault()?.Message; } else { csentry = ImportProcessor.GetCSEntryChange(group, schema.Types[SchemaConstants.Group], this.config); } return(csentry); }
public Task GetObjectImportTask(Schema schema, BlockingCollection <object> collection, CancellationToken cancellationToken) { Task t = new Task(() => { DomainList list = this.config.DomainsService.List(this.config.CustomerID); foreach (Domain d in list.Domains) { string dn = this.GetDNValue(d); if (dn == null) { Logger.WriteLine($"Domain {d} had no DN, ignoring"); continue; } collection.Add(ImportProcessor.GetCSEntryChange(d, schema.Types[SchemaConstants.Domain], this.config)); } }, cancellationToken); t.Start(); return(t); }
private CSEntryChange GetCSEntryForFeature(Feature feature, MmsSchema schema) { return(ImportProcessor.GetCSEntryChange(feature, schema.Types[SchemaConstants.Feature], this.config)); }
private CSEntryChange GetCSEntryForBuilding(Building building, MmsSchema schema, IManagementAgentParameters config) { return(ImportProcessor.GetCSEntryChange(building, schema.Types[SchemaConstants.Building], config)); }
public Task GetObjectImportTask(Schema schema, BlockingCollection <object> collection, CancellationToken cancellationToken) { if (this.ObjectClass != SchemaConstants.User) { if (schema.Types.Contains(SchemaConstants.User)) { // This function doesn't need to run for advanced users, if the user class will be called. return(null); } } HashSet <string> fieldNames = new HashSet <string> { SchemaConstants.PrimaryEmail, SchemaConstants.ID }; foreach (var type in this.config.CustomUserObjectClasses) { if (schema.Types.Contains(type)) { foreach (string field in ManagementAgent.Schema[type].GetFieldNames(schema.Types[type])) { fieldNames.Add(field); } } } if (schema.Types.Contains(SchemaConstants.User)) { foreach (string field in ManagementAgent.Schema[SchemaConstants.User].GetFieldNames(schema.Types[SchemaConstants.User])) { fieldNames.Add(field); } fieldNames.Add($"customSchemas/{SchemaConstants.CustomGoogleAppsSchemaName}"); } string fields = $"users({string.Join(",", fieldNames)}),nextPageToken"; Task t = new Task(() => { try { Logger.WriteLine("Requesting fields: " + fields); Logger.WriteLine("Query filter: " + (this.config.UserQueryFilter ?? "<none>")); ParallelOptions op = new ParallelOptions() { MaxDegreeOfParallelism = MAConfigurationSection.Configuration.ImportThreads, CancellationToken = cancellationToken }; Parallel.ForEach(this.config.UsersService.GetUsers(this.config.CustomerID, fields, this.config.UserQueryFilter), op, user => { SchemaType type = schema.Types[SchemaConstants.User]; if (!string.IsNullOrWhiteSpace(this.config.UserRegexFilter)) { if (!Regex.IsMatch(user.PrimaryEmail, this.config.UserRegexFilter, RegexOptions.IgnoreCase)) { return; } } if (user.CustomSchemas != null) { if (user.CustomSchemas.ContainsKey(SchemaConstants.CustomGoogleAppsSchemaName)) { if (user.CustomSchemas[SchemaConstants.CustomGoogleAppsSchemaName].ContainsKey(SchemaConstants.CustomSchemaObjectType)) { string objectType = (string)user.CustomSchemas[SchemaConstants.CustomGoogleAppsSchemaName][SchemaConstants.CustomSchemaObjectType]; if (schema.Types.Contains(objectType)) { type = schema.Types[objectType]; } } } } collection.Add(ImportProcessor.GetCSEntryChange(user, type, this.config), cancellationToken); return; }); } catch (OperationCanceledException) { } }, cancellationToken); t.Start(); return(t); }
private CSEntryChange GetCSEntryForCalendar(CalendarResource calendar, MmsSchema schema, IManagementAgentParameters config) { return(ImportProcessor.GetCSEntryChange(calendar, schema.Types[SchemaConstants.Calendar], config)); }