<?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: Obtaining my email address from metadata? in Administration and Deployment</title>
    <link>https://communities.sas.com/t5/Administration-and-Deployment/Obtaining-my-email-address-from-metadata/m-p/511230#M14897</link>
    <description>&lt;P&gt;Hi Bart,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Depending on the context in which the SAS code is running you may&amp;nbsp;potentially&amp;nbsp;have a &amp;amp;_METAPERSON macro variable, containing the identity name, although I assume you have %put _all_ and not found it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The &amp;amp;_METAUSER macro variable does look like a login user id but in mixed-case user and user@domain format instead of the low-case user and domain\user format you have in your metadata. A transformation of user@domain to domain\user and a case-insensitive search of metadata Login objects&amp;nbsp;should locate the Login object for the logged in user (Person). You can then follow the association to the Person object and then another association to the one or more Email objects for that Person. You could do this using data step metadata functions like&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;&amp;nbsp;suggested or use the standard SAS &lt;A href="https://documentation.sas.com/?docsetId=bisecag&amp;amp;docsetTarget=n024i4nqa5b12qn1lfek77h69ns5.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_self"&gt;%MDUEXTR&lt;/A&gt; macro to get all user info into SAS tables to query. We also have some similar macros at&amp;nbsp;&lt;A href="https://github.com/Metacoda/idsync-utils" target="_blank"&gt;https://github.com/Metacoda/idsync-utils&lt;/A&gt; that can extract various aspects of SAS identity metadata into SAS tables:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="https://github.com/Metacoda/idsync-utils/blob/master/sasautos/metacodaidentityloginextract.sas" target="_self"&gt;%metacodaIdentityLoginExtract&lt;/A&gt; will give you a table with userId, identityName, and identityObjId (among others)&lt;/LI&gt;
&lt;LI&gt;&lt;A href="https://github.com/Metacoda/idsync-utils/blob/master/sasautos/metacodapersonemailextract.sas" target="_self"&gt;%metacodaPersonEmailExtract&lt;/A&gt; will&lt;SPAN&gt;&amp;nbsp;give you a table with (email) address, personName, and personObjId (among others)&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;SPAN&gt;A join of those 2 tables (on object id) with a filter on userId with an appropriately transformed&amp;nbsp;&amp;amp;_METAUSER should give you the email address(es) for the user. If you are doing identity sync then you might&amp;nbsp;cache such a table at the same time to facilitate easy lookups.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Cheers&lt;BR /&gt;Paul&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 07 Nov 2018 22:59:41 GMT</pubDate>
    <dc:creator>PaulHomes</dc:creator>
    <dc:date>2018-11-07T22:59:41Z</dc:date>
    <item>
      <title>Obtaining my email address from metadata?</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/Obtaining-my-email-address-from-metadata/m-p/511032#M14884</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to obtain my email address from SAS metadata but cannot seem to get it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is that I don't know who I am in my SAS session.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I expected &amp;amp;_METAUSER to provide the Person name that I could use to search the Persons metadata objects for:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="3.png" style="width: 558px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/24730iA33BAEB777BEC372/image-size/large?v=v2&amp;amp;px=999" role="button" title="3.png" alt="3.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but it seems that &amp;amp;_METAUSER provides the&amp;nbsp;account that the SAS session used to identify itself to the metadata server.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;This is me in Management Console:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="7-11-2018 15-15-27.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/24727iC343D4C095F7BA70/image-size/large?v=v2&amp;amp;px=999" role="button" title="7-11-2018 15-15-27.png" alt="7-11-2018 15-15-27.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what &amp;amp;_metauser says when I %put it on my SASApp workspace server (Linux):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;22 %put &amp;amp;=_metauser;
_METAUSER=bart.heinsius.sas-b&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what &amp;amp;_metauser says when I %put it on my SASConnect workspace server (Windows):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;22 %put &amp;amp;=_metauser;
_METAUSER=Bart.Heinsius-B@EUROPE&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I thought that maybe they were login accounts so I could search metadata for them, but they are not:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/24728i1D778F48BC3925D5/image-size/large?v=v2&amp;amp;px=999" role="button" title="2.png" alt="2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas on how&amp;nbsp;I can find my Person name?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Bart Heinsius&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 14:29:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/Obtaining-my-email-address-from-metadata/m-p/511032#M14884</guid>
      <dc:creator>bheinsius</dc:creator>
      <dc:date>2018-11-07T14:29:06Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining my email address from metadata?</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/Obtaining-my-email-address-from-metadata/m-p/511060#M14887</link>
      <description>&lt;P&gt;Maybe something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   length 
      userUri mailUri eMail $ 250
   ;
   User = "&amp;amp;_MetaUser";

   if index(User, '@') then do;
      User = lowcase(cats(scan(User, 2, '@'), '\', scan(User, 1, '@')));
   end;
   

   searchUri = cats("omsobj:Person?Person[Logins/Login[@UserId = '", User ,"']]");
   userUri = "";
   rc = metadata_getnobj(searchUri, 1, userUri);

   if rc = 1 then do;
      mailUri = "";
      rc = metadata_getnasn(userUri, 'EMailAddresses', 1, mailUri);
      
      if rc = 1 then do;
         rc = metadata_getattr(mailUri, 'Address', eMail);
      end;

   end;
/*
   shorter if you see a chance to get the user's name as saved in the Person-Meta-object,
   check &amp;amp;_ClientUserID!!
 
   UriMail = "";
   UriMail = cats("omsobj:Email?Email[@EmailType contains 'dienstlich']",
               "[Persons/Person[Logins/Login[@UserId = '&amp;amp;_ClientUserId.']]");

   eMail = "";
   rc = metadata_getattr(UriMail, 'Address', eMail);
*/
   put _all_;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 07 Nov 2018 15:53:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/Obtaining-my-email-address-from-metadata/m-p/511060#M14887</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2018-11-07T15:53:33Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining my email address from metadata?</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/Obtaining-my-email-address-from-metadata/m-p/511074#M14890</link>
      <description>&lt;P&gt;Andreas,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you but what I am really looking for is an option or macvar that&amp;nbsp;I can relate 1-on-1 to the Person name, or any other attribute that the Person has. Is there no way to get the yellow value below directly from a SAS program?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="4.png" style="width: 589px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/24732i23B723826AB8671F/image-size/large?v=v2&amp;amp;px=999" role="button" title="4.png" alt="4.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 20:57:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/Obtaining-my-email-address-from-metadata/m-p/511074#M14890</guid>
      <dc:creator>bheinsius</dc:creator>
      <dc:date>2018-11-07T20:57:36Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining my email address from metadata?</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/Obtaining-my-email-address-from-metadata/m-p/511230#M14897</link>
      <description>&lt;P&gt;Hi Bart,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Depending on the context in which the SAS code is running you may&amp;nbsp;potentially&amp;nbsp;have a &amp;amp;_METAPERSON macro variable, containing the identity name, although I assume you have %put _all_ and not found it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The &amp;amp;_METAUSER macro variable does look like a login user id but in mixed-case user and user@domain format instead of the low-case user and domain\user format you have in your metadata. A transformation of user@domain to domain\user and a case-insensitive search of metadata Login objects&amp;nbsp;should locate the Login object for the logged in user (Person). You can then follow the association to the Person object and then another association to the one or more Email objects for that Person. You could do this using data step metadata functions like&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;&amp;nbsp;suggested or use the standard SAS &lt;A href="https://documentation.sas.com/?docsetId=bisecag&amp;amp;docsetTarget=n024i4nqa5b12qn1lfek77h69ns5.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_self"&gt;%MDUEXTR&lt;/A&gt; macro to get all user info into SAS tables to query. We also have some similar macros at&amp;nbsp;&lt;A href="https://github.com/Metacoda/idsync-utils" target="_blank"&gt;https://github.com/Metacoda/idsync-utils&lt;/A&gt; that can extract various aspects of SAS identity metadata into SAS tables:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="https://github.com/Metacoda/idsync-utils/blob/master/sasautos/metacodaidentityloginextract.sas" target="_self"&gt;%metacodaIdentityLoginExtract&lt;/A&gt; will give you a table with userId, identityName, and identityObjId (among others)&lt;/LI&gt;
&lt;LI&gt;&lt;A href="https://github.com/Metacoda/idsync-utils/blob/master/sasautos/metacodapersonemailextract.sas" target="_self"&gt;%metacodaPersonEmailExtract&lt;/A&gt; will&lt;SPAN&gt;&amp;nbsp;give you a table with (email) address, personName, and personObjId (among others)&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;SPAN&gt;A join of those 2 tables (on object id) with a filter on userId with an appropriately transformed&amp;nbsp;&amp;amp;_METAUSER should give you the email address(es) for the user. If you are doing identity sync then you might&amp;nbsp;cache such a table at the same time to facilitate easy lookups.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Cheers&lt;BR /&gt;Paul&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Nov 2018 22:59:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/Obtaining-my-email-address-from-metadata/m-p/511230#M14897</guid>
      <dc:creator>PaulHomes</dc:creator>
      <dc:date>2018-11-07T22:59:41Z</dc:date>
    </item>
    <item>
      <title>Re: Obtaining my email address from metadata?</title>
      <link>https://communities.sas.com/t5/Administration-and-Deployment/Obtaining-my-email-address-from-metadata/m-p/511444#M14919</link>
      <description>&lt;P&gt;So apparently there is no ready-made person id available in the SAS session (which sort of amazes me),&amp;nbsp;apart from the metaperson that I don't have in my sas session.&lt;/P&gt;&lt;P&gt;So&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;'&amp;nbsp;code does what&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18432"&gt;@PaulHomes&lt;/a&gt;&amp;nbsp;explains so I used it and it works like a charm.&lt;/P&gt;&lt;P&gt;Thank you both.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Nov 2018 17:04:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Administration-and-Deployment/Obtaining-my-email-address-from-metadata/m-p/511444#M14919</guid>
      <dc:creator>bheinsius</dc:creator>
      <dc:date>2018-11-08T17:04:41Z</dc:date>
    </item>
  </channel>
</rss>

