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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
PriyaJha
Helper I
Helper I

How to identify session user of a notebook

Hi,

I am trying to identify what user name does a notebook takes when it is been executed by an individual and via data pipeline.

 

I am executing following code in a notebook--

getpass.getuser()

 

The ouuput is -- trusted-service-user

 

When this notebook is called in a data pipeline, the output is same.

 

Please explain what is trusted-service-user and how to idenify execution user or session user of a notebook when triggered by an individual and when called in a pipeline.

1 ACCEPTED SOLUTION
spencer_sa
Super User
Super User

Hi @PriyaJha 

 

getpass.getuser() is likely to return the internal user that the notebook is exeecuting as on the Spark node.
If you want to get the name of the logged in user (as controlled by Entra ID / Fabric), then you should use the following function to return the user running the job.

mssparkutils.env.getUserName()

This returns the user who is executing the notebook.

Be aware we have seen some unusual behaviour in the Monitoring hub when user A is executing a pipeline + notebook activity owned by user B.  In this case we have seen the pipeline executing under user A, but the notebook executing as user B.

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @PriyaJha ,

Did the above suggestions help with your scenario? if that is the case, you can consider Kudo or Accept the helpful suggestions to help others who faced similar requirements.

If these also don't help, please share more detailed information and description to help us clarify your scenario to test.

Regards,

Xiaoxin Sheng

spencer_sa
Super User
Super User

Hi @PriyaJha 

 

getpass.getuser() is likely to return the internal user that the notebook is exeecuting as on the Spark node.
If you want to get the name of the logged in user (as controlled by Entra ID / Fabric), then you should use the following function to return the user running the job.

mssparkutils.env.getUserName()

This returns the user who is executing the notebook.

Be aware we have seen some unusual behaviour in the Monitoring hub when user A is executing a pipeline + notebook activity owned by user B.  In this case we have seen the pipeline executing under user A, but the notebook executing as user B.

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Fabric Update Carousel

Fabric Monthly Update - September 2025

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

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