Hi Kevin,
If you are using script to retrieve the security role of the current user then you can use the below code.
Xrm.Page.context.getUserRoles();
The above code return all the security that the current user have.
If you are using C# then use following code.
string userRolesName
= string.Empty;
//Create
Fetch xml string
string fetch
= "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>"
+ "<entity name='role'>"
+ "<attribute name='name' />"
+ "<attribute name='businessunitid' />"
+ "<attribute name='roleid' />"
+ "<order attribute='name' descending='false' />"
+ "<link-entity name='systemuserroles' from='roleid' to='roleid' visible='false' intersect='true'>"
+ "<link-entity name='systemuser' from='systemuserid' to='systemuserid' alias='ab'>"
+ "<filter type='and'>"
+ "<condition attribute='fullname' operator='eq' value='XXXXXXXX'/>"
+ "</filter>"
+ "</link-entity>"
+ "</link-entity>"
+ "</entity>"
+ "</fetch>";
//retrieve
the security role using Organization Service
EntityCollection securityRoles
= _orgService.RetrieveMultiple(newFetchExpression(fetch));
foreach(var role in securityRoles.Entities)
{
userRolesName
+= role["name"].ToString() + "\n";
}
Inogic |
Blog | news@inogic.com
If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"