<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Find notebook executing user in Data Engineering</title>
    <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Find-notebook-executing-user/m-p/4645773#M8512</link>
    <description>&lt;P&gt;Thanks. My reason to look at userName is to identify if the user is named user or SPN and based on that initialize credential class to call Fabric APIs from notebook. In case of named user it returns the entire email addres and I can easily put a regex to verify it. Should I assume it will always return None/empty/exception if the user is SPN/MI?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Gayatri&lt;/P&gt;</description>
    <pubDate>Wed, 09 Apr 2025 23:04:44 GMT</pubDate>
    <dc:creator>g3kuser</dc:creator>
    <dc:date>2025-04-09T23:04:44Z</dc:date>
    <item>
      <title>Find notebook executing user</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Find-notebook-executing-user/m-p/4644395#M8488</link>
      <description>&lt;DIV&gt;&lt;SPAN&gt;I am trying to find notebook executing user using&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;mssparkutils.env.getUserName() method.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;This works fine when executing user is named user but fails when the user is SPN as the notebook owner is SPN.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Does this method not return user details if it is SPN?&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thanks,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Gayatri&lt;/DIV&gt;</description>
      <pubDate>Wed, 09 Apr 2025 06:59:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Find-notebook-executing-user/m-p/4644395#M8488</guid>
      <dc:creator>g3kuser</dc:creator>
      <dc:date>2025-04-09T06:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: Find notebook executing user</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Find-notebook-executing-user/m-p/4644974#M8499</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/788986"&gt;@g3kuser&lt;/a&gt;,&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Thank you for reaching out in Microsoft Community Forum.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Please follow below steps to Handle mssparkutils.env.getUserName() with SPNs;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;1.mssparkutils.env.getUserName() works for named users, but does not reliably return SPN names.&lt;/P&gt;
&lt;P&gt;2.SPNs are service accounts, and not treated as interactive users, so this method may return null or empty.&lt;/P&gt;
&lt;P&gt;3.Pass the user or SPN name as a parameter to the notebook when triggered via pipeline or API.&lt;/P&gt;
&lt;P&gt;4.Use mssparkutils.env.getExecutionId() to trace the notebook run or log trigger identity externally.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Please continue using Microsoft community forum.&lt;BR /&gt;&lt;BR /&gt;If you found this post helpful, please consider marking it as "&lt;STRONG&gt;Accept as Solution&lt;/STRONG&gt;" and give it a '&lt;STRONG&gt;Kudos&lt;/STRONG&gt;'. if it was helpful. help other members find it more easily.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Pavan.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Apr 2025 12:09:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Find-notebook-executing-user/m-p/4644974#M8499</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-04-09T12:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: Find notebook executing user</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Find-notebook-executing-user/m-p/4645058#M8500</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/788986"&gt;@g3kuser&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;mssparkutils.env.getUserId()&lt;SPAN&gt;&amp;nbsp; might works more reliably and can return the ID even when the notebook is executed by a service principal&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Apr 2025 12:49:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Find-notebook-executing-user/m-p/4645058#M8500</guid>
      <dc:creator>nilendraFabric</dc:creator>
      <dc:date>2025-04-09T12:49:39Z</dc:date>
    </item>
    <item>
      <title>Re: Find notebook executing user</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Find-notebook-executing-user/m-p/4645773#M8512</link>
      <description>&lt;P&gt;Thanks. My reason to look at userName is to identify if the user is named user or SPN and based on that initialize credential class to call Fabric APIs from notebook. In case of named user it returns the entire email addres and I can easily put a regex to verify it. Should I assume it will always return None/empty/exception if the user is SPN/MI?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Gayatri&lt;/P&gt;</description>
      <pubDate>Wed, 09 Apr 2025 23:04:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Find-notebook-executing-user/m-p/4645773#M8512</guid>
      <dc:creator>g3kuser</dc:creator>
      <dc:date>2025-04-09T23:04:44Z</dc:date>
    </item>
    <item>
      <title>Re: Find notebook executing user</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Find-notebook-executing-user/m-p/4648367#M8538</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/788986"&gt;@g3kuser&lt;/a&gt;,&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Thank you for reaching out in Microsoft Community Forum.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/913195"&gt;@nilendraFabric&lt;/a&gt;&amp;nbsp; for the helpful response.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;mssparkutils.env.getUserName() will return a valid email address for named interactive users&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Use a simple check like this to differentiate:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;user_name = mssparkutils.env.getUserName()&lt;/P&gt;
&lt;P&gt;if user_name and "@" in user_name:&lt;BR /&gt;# Named user&lt;BR /&gt;else:&lt;BR /&gt;# SPN or MI&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Please continue using Microsoft community forum.&lt;BR /&gt;&lt;BR /&gt;If you found this post helpful, please consider marking it as "&lt;STRONG&gt;Accept as Solution&lt;/STRONG&gt;" and give it a '&lt;STRONG&gt;Kudos&lt;/STRONG&gt;'. if it was helpful. help other members find it more easily.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Pavan.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Apr 2025 09:58:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Find-notebook-executing-user/m-p/4648367#M8538</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-04-11T09:58:23Z</dc:date>
    </item>
    <item>
      <title>Re: Find notebook executing user</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Find-notebook-executing-user/m-p/4651007#M8572</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/788986"&gt;@g3kuser&lt;/a&gt;,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please "&lt;/SPAN&gt;&lt;STRONG&gt;Accept&amp;nbsp; as&amp;nbsp; Solution&lt;/STRONG&gt;&lt;SPAN&gt;" and give a '&lt;/SPAN&gt;&lt;STRONG&gt;Kudos&lt;/STRONG&gt;&lt;SPAN&gt;' so other members can easily find it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Pavan.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Apr 2025 09:33:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Find-notebook-executing-user/m-p/4651007#M8572</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-04-14T09:33:08Z</dc:date>
    </item>
    <item>
      <title>Re: Find notebook executing user</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Find-notebook-executing-user/m-p/4651223#M8573</link>
      <description>&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Gayatri&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Apr 2025 11:02:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Find-notebook-executing-user/m-p/4651223#M8573</guid>
      <dc:creator>g3kuser</dc:creator>
      <dc:date>2025-04-14T11:02:23Z</dc:date>
    </item>
  </channel>
</rss>

