Forum Discussion
How to identify session user of a notebook
- 1 year ago
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.
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.
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.