Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
smpa01
Super User
Super User

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

john.doe@company.com

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
1 ACCEPTED SOLUTION

mssparkutils.env.getUser

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

View solution in original post

5 REPLIES 5
nilendraFabric
Super User
Super User

Have you tried this

 

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

 

 

sorry, I meant fabric notebook and not databricks notebook

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

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.

mssparkutils.env.getUser

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Thanks for sharing this. I haven't tried this 🙂

Helpful resources

Announcements
November Fabric Update Carousel

Fabric Monthly Update - November 2025

Check out the November 2025 Fabric update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors