Hello Experts,
I use below code to assign security role to a single user.
public static void AssignSecurityRole(Guid guidSystemUserId, Guid guidSecurityRoleId, IOrganizationService crmService)
{
// Create new Associate Request object for creating a N:N relationsip between User and Security
AssociateRequest objAssociateRequest = new AssociateRequest();
// Create related entity reference object for associating relationship
// In this case we SystemUser entity reference
objAssociateRequest.RelatedEntities = new EntityReferenceCollection();
objAssociateRequest.RelatedEntities.Add(new EntityReference("systemuser", guidSystemUserId));
// Create new Relationship object for System User & Security Role entity schema and assigning it
// to request relationship property
objAssociateRequest.Relationship = new Relationship("systemuserroles_association");
// Create target entity reference object for associating relationship
objAssociateRequest.Target = new EntityReference("role", guidSecurityRoleId);
// Passing AssosiateRequest object to Crm Service Execute method for assigning Security Role to User
crmService.Execute(objAssociateRequest);
}
I am executing above code from my console utility. I see performance degrade when I need to assign multiple security roles to 10k users.
Need you help and guidance to improve my performance of the code.
Thanks,
Bipin
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.
User | Count |
---|---|
11 | |
7 | |
7 | |
6 | |
4 |
User | Count |
---|---|
37 | |
23 | |
19 | |
8 | |
8 |