Retrieve all security roles of user RRS feed

  • Question

  • Hello,

    I would like to retrieve all security roles names of a specific user.
    I want to use generic Entity object (like Entity('account').

    Thank you in advance.

    Wednesday, August 10, 2016 3:02 PM


  • Hi Kevin,
    If you are using script to retrieve the security role of the current user then you can use the below code.
    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"

    • Marked as answer by K. MA Thursday, August 11, 2016 6:17 AM
    Thursday, August 11, 2016 5:20 AM