Forum Discussion
Find notebook executing user
- Anonymous1 year ago
Hi g3kuser,
Thank you for reaching out in Microsoft Community Forum.
Please follow below steps to Handle mssparkutils.env.getUserName() with SPNs;
1.mssparkutils.env.getUserName() works for named users, but does not reliably return SPN names.
2.SPNs are service accounts, and not treated as interactive users, so this method may return null or empty.
3.Pass the user or SPN name as a parameter to the notebook when triggered via pipeline or API.
4.Use mssparkutils.env.getExecutionId() to trace the notebook run or log trigger identity externally.
Please continue using Microsoft community forum.
If you found this post helpful, please consider marking it as "Accept as Solution" and give it a 'Kudos'. if it was helpful. help other members find it more easily.
Regards,
Pavan.
Hi g3kuser,
Thank you for reaching out in Microsoft Community Forum.
Please follow below steps to Handle mssparkutils.env.getUserName() with SPNs;
1.mssparkutils.env.getUserName() works for named users, but does not reliably return SPN names.
2.SPNs are service accounts, and not treated as interactive users, so this method may return null or empty.
3.Pass the user or SPN name as a parameter to the notebook when triggered via pipeline or API.
4.Use mssparkutils.env.getExecutionId() to trace the notebook run or log trigger identity externally.
Please continue using Microsoft community forum.
If you found this post helpful, please consider marking it as "Accept as Solution" and give it a 'Kudos'. if it was helpful. help other members find it more easily.
Regards,
Pavan.
- g3kuser1 year agoHelper II
Thank you. Yes I implemented the same with the additional check on userName against email regex. This is added only to make it future proof. If MS changes the definition of the method and ends up returning a actual SPN name instead of exception getting raised as of today email regex will help in differentiating.
Thanks,
Gayatri