Forum Discussion

smpa01's avatar
smpa01
Community Champion
1 year ago
Solved

upn

Can databricks notebook return the current UPN (equiavalent DAX USERPRINCIPALNAME())?

select current_user()

returns

trusted-service-user which is not useable.

I need it to return the following

[email protected]

 

5 Replies

  • Have you tried this

     

    user = dbutils.notebook.entry_point.getDbutils().notebook().getContext().userName().get()
    print(user)

     

     

    • smpa01's avatar
      smpa01
      Community Champion

      sorry, I meant fabric notebook and not databricks notebook

      • nilendraFabric's avatar
        nilendraFabric
        Super User

        Fabric Notebooks execute under a service identity rather than the context of an individual user.

        thats why When you run a statement such as `select current_user()`, the output is the service account (“trusted-service-user”) rather than the individual’s email address

         

        This is a known limitation which has been discussed here in forum and enhancements to be made  to the mssparkutils package.