none
Problem: ECMA 2.2 custom agent multiple object types RRS feed

  • Question

  • I am having a wired problem with importing data using a custom agent that integrates with Dynamics 365 (on prem)

    My issue is with the import process. The code imports users and business roles. The code is below. When I run the Import profile, the Sync manager shows users got imported and not roles. When I debug the code, importReturnInfo shows both users and roles but Sync manager and agent's CS only show users. 

    Here is another confusing part. I tried to process the roles before the users in the GetImportEntries. It worked and the Sync manager is importing both rules and users. However, when I delete any role from Dynamics, the sync engine doesn't recognize the deleted role. Any idea what I am missing? Thanks

        public GetImportEntriesResults GetImportEntries(GetImportEntriesRunStep importRunStep)
            {
    
                DynamicsUserProfileQueryResult dynamicsUserProfileQueryResult = new DynamicsUserProfileQueryResult();
                List<CSEntryChange> csentries = new List<CSEntryChange>();
                GetImportEntriesResults importReturnInfo;
    
    
                if (personMoreToImport)
                {
    
                    dynamicsUserProfileQueryResult = Connector.GetDynamicsUsers(ImportPageSize, userPageNumber);
    
                    userPageNumber++;
                    personMoreToImport = dynamicsUserProfileQueryResult.QueryPagingCookie != null;
                    ProcessImportedDynamicsUsers(dynamicsUserProfileQueryResult, csentries);
    
                }
    
    
                //if we try to add users first, roles are not being added for some reason
                if (rolesMoreToImport)
                {
                    var businessRoles = ImportBusinessRoles();
                    foreach (var businessRole in businessRoles)
                    {
                        CSEntryChange entry = CSEntryChange.Create();
                        entry.ObjectModificationType = ObjectModificationType.Add;
                        entry.ObjectType = BusinessRole;
    
                        if (businessRole.RoleId.HasValue)
                            entry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("RoleId", businessRole.RoleId.ToString()));
                        if (!String.IsNullOrWhiteSpace(businessRole.RoleText))
                            entry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd("RoleName", businessRole.RoleText));
    
                        entry.DN = String.Format("CN={0},O=Role", businessRole.RoleText);
    
    
                        csentries.Add(entry);
                    }
                    rolesMoreToImport = false;
    
                }
    
                importReturnInfo = new GetImportEntriesResults()
                {
                    MoreToImport = rolesMoreToImport,
                    CSEntries = csentries
                };
                return importReturnInfo;
    
    
            }
    



    Ahmed is an independent consultant in Ottawa, Canada specialized in .NET, Biztalk, WCF, WPF, TFS and other Microsoft technologies.

    Blog: http://lajak.wordpress.com

    Twitter: ahmedalasaad

    Thursday, January 9, 2020 8:07 PM

Answers

  • Full Import. 

    I ended up creating another agent just to import the roles.


    Ahmed is an independent consultant in Ottawa, Canada specialized in .NET, Biztalk, WCF, WPF, TFS and other Microsoft technologies.

    Blog: http://lajak.wordpress.com

    Twitter: ahmedalasaad

    Monday, March 30, 2020 5:59 PM

All replies

  • Are you doing full import or delta import? Do you have any errors/warnings during import? Have you done full synchronization after import?

    Borys Majewski, Identity Management Solutions Architect (Blog: IDArchitect.NET)

    Thursday, January 16, 2020 10:40 PM
  • Full Import. 

    I ended up creating another agent just to import the roles.


    Ahmed is an independent consultant in Ottawa, Canada specialized in .NET, Biztalk, WCF, WPF, TFS and other Microsoft technologies.

    Blog: http://lajak.wordpress.com

    Twitter: ahmedalasaad

    Monday, March 30, 2020 5:59 PM