Home

Jul 9, 2009

Programmatically Assign a Custom Role to CRM Users

When you create Custom entity, It is obvious to face this situation.
By default, Custom Entity Create, Read , Write and other privileges are set to system administrator role.
If you require to access this custom entity by users having roles other than System administrator then you would require to create a custom role and assign “Create, Read , Write” privilege to the newly created role. Then add the custom role to user roles. If there are 100’s of user then it would be difficult to assign the custom role manually.
Here is how you will assign custom or system roles programmatically.

1. Get the Root business Unit.
2. Create a Custom Role for Root business unit.
3. Assign Privilege to Custom role using AddPrivilegesRole Message
4. Custom role can be accessed across all child Business Units.
5. Retrieve All Users
6. Then Assign Newly created custom Role to All Users using AssignUserRolesRoleRequest message by looping through all users.

Here are few links to above messages

AddPrivilegesRole
http://technet.microsoft.com/en-us/library/cc151187.aspx
AssignUserRolesRoleRequest
http://msdn.microsoft.com/en-us/library/bb955917.aspx

Jai Ho Crm

No comments: