Forum Discussion

aleksvp's avatar
aleksvp
Helper II
11 months ago
Solved

USERPRINCIPALNAME() in Public Web Reports

I'm trying to control a feature of my report based on the idenfied or anonymous access (the report is published on the web, but it is also accessed by logged in users).

 

I imagined that USERPRINCIPALNAME() would return blank when the acess is the public report, but it is returning the user who published the report. 

 

Is this the expected behavor? Is there another way to check if it is a unidentified access?

 

Tks

  • Hi aleksvp

     

    You're seeing expected behavior.

    Publish to web is anonymous: there's no viewer sign-in, and RLS isn’t supported. In that scenario, identity functions like USERPRINCIPALNAME() don't reflect the actual viewer-what you observe (returning the publisher/owner) is a known side effect of rendering without user authentication (Publish to web, see "Viewing requires no authentication" and "Reports using row-level security" not supported).

    If you need to toggle features based on who is viewing, don’t use Publish to web. Use a secure, authenticated path where the service knows the user.

     

    I recommend you maintain two reports for this use case: a public "publish to web" version with no identity-based behavior, and a secure version (workspace/app/secure embed) where your DAX uses USERPRINCIPALNAME() or RLS as intended.

     

    If you found this helpful, consider giving some Kudos. If I answered your question or solved your problem, please mark this as the solution.

2 Replies

  • Hi aleksvp

     

    You're seeing expected behavior.

    Publish to web is anonymous: there's no viewer sign-in, and RLS isn’t supported. In that scenario, identity functions like USERPRINCIPALNAME() don't reflect the actual viewer-what you observe (returning the publisher/owner) is a known side effect of rendering without user authentication (Publish to web, see "Viewing requires no authentication" and "Reports using row-level security" not supported).

    If you need to toggle features based on who is viewing, don’t use Publish to web. Use a secure, authenticated path where the service knows the user.

     

    I recommend you maintain two reports for this use case: a public "publish to web" version with no identity-based behavior, and a secure version (workspace/app/secure embed) where your DAX uses USERPRINCIPALNAME() or RLS as intended.

     

    If you found this helpful, consider giving some Kudos. If I answered your question or solved your problem, please mark this as the solution.

  • v-lgarikapat's avatar
    v-lgarikapat
    Community Support

    Hi aleksvp ,

     

    Thanks for reaching out to the Microsoft fabric community forum.

    tayloramy ,

    Thanks for your prompt response

    aleksvp 

     

    I wanted to follow up and see if you had a chance to review the information shared by tayloramy . If you have any further questions or need additional assistance, feel free to reach out.

     

    We appreciate your engagement and thank you for being an active part of the community.

    Best regards,
    Lakshmi
    .