Assign role to User

Sometimes we need to manage roles programmatically with plugins to fulfill our customer requirements. This is great to allow Users to see data and append privileges. Find below a method that will assign a role to a user(Both sent as parameters).

/// Assign Role to the specified User
public static void Assign_Role_User(Guid User_ID, EntityReference Role, IOrganizationService Service)
                        new Relationship("systemuserroles_association"),
                        new EntityReferenceCollection() { Role });



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s