Forum Discussion

tombrox's avatar
tombrox
New Member
4 years ago
Solved

Security - test as role

Hi.   I am fairly new to powerBI. We have a workspace, one dataset - three reports. Also we have 3 roles. As far as I have understood, I should be able to, on each role, to do a: Test as Role. Howe...
  • v-luwang-msft's avatar
    4 years ago

    Hi tombrox ,

    For this case, first you need to test locally with different roles to see if data is available.

    In addition, most of the cases I encountered were caused by the following functions returning different values in service and desktop.

    USERNAME():

    Returns the domain name and username from the credentials given to the system at connection time.

    USEPRINCIPALNAME():

    Returns the user principal name.

    USEROBJECTID():

    Returns the current user's Object ID from Azure AD or security identifier (SID).

    I created a table local:

     

    Then create a measure by following DAX:

    RETURN =

    SWITCH (

        MAX ('Table'[Column1]),

        "USERNAME", USERNAME (),

        "USEPRINCIPALNAME", USERPRINCIPALNAME (),

        "USEROBJECTID", USEROBJECTID ()

    )

    It returned me the following result when I user Power BI Desktop. It showed data about my local information.

     

     

    Then I publish it. And open the report on Power BI service. It shows a different result than that on Power BI Desktop. USERNAME() and USEPRINCIPALNAME() return is the name of the account I am logged into, USEROBJECTID() returns different results when the workspace capacity is different. More details about workspace capacity refer official article.

    When the workspace where the report published to is premium capacity(Premium per user and premium per capacity )

     

     

    When the workspace where the report published to is shared capacity:

     

     

    And in Windows Active Directory, a User Principal Name (UPN) is the name of a system user in an email address format. A UPN (for example: [email protected]) consists of the user name (logon name), separator (the @ symbol), and domain name (UPN suffix). if computer not in a domain and it only in a work group, It will return the same value as using USERNAME().

     

    In conclusion, in Power BI Desktop, USERNAME() will return domain/username and USEPRINCIPALNAME() function will return [email protected].However, on Power BI Service, both USERNAME() and USEPRINCIPALNAME() will return [email protected].

     

    Did I answer your question? Mark my post as a solution!


    Best Regards

    Lucien