<?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: Best way to assign password to variable? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Best-way-to-assign-password-to-variable/m-p/690771#M210168</link>
    <description>&lt;P&gt;I see; after reading the doc myself, it is clear that GETOPTION will not return the value from any option that contains a password.&lt;/P&gt;
&lt;P&gt;Which means that you have to find another way to supply the password to your code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you need to retrieve the password of a system user (one that can run a workspace server), then you won't find that in metadata anyway, as it (not the password, but the hash from it) is stored in the authentication source (local operating system or LDAP).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It seems you want to retrieve a ticket from the Logon Manager; what do you intend to do with that?&lt;/P&gt;</description>
    <pubDate>Sun, 11 Oct 2020 09:00:13 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-10-11T09:00:13Z</dc:date>
    <item>
      <title>Best way to assign password to variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Best-way-to-assign-password-to-variable/m-p/690705#M210138</link>
      <description>&lt;P&gt;Hi Experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a .sas file "test.sas" which has a macro with ID and pass.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro test;
options metauser="testuser" metapass="{SAS002}FHIHJKLNAHIFGHRTY";
%mend;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I want to read the metauser and metapass values into a variable in my program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options mprint mlogic;
%include "/mypath/test.sas";
%test;
%let id=%sysfunc(getoption(metauser));
%let pass=%sysfunc(getoption(metapass));
%put &amp;amp;id;
%put &amp;amp;pass;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;79         %let id=%sysfunc(getoption(metauser));
 80         %let pass=%sysfunc(getoption(metapass));
 81         %put &amp;amp;id;
 testuser
 82         %put &amp;amp;pass;
 XXXXXXXX&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am able to read the username but password is always XXXXX. I read the documentation for getoption and it's behaving as expected for passwords.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please advise good way to read the ID and pass in this scenario.&lt;/P&gt;</description>
      <pubDate>Sat, 10 Oct 2020 18:35:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Best-way-to-assign-password-to-variable/m-p/690705#M210138</guid>
      <dc:creator>AnandVyas</dc:creator>
      <dc:date>2020-10-10T18:35:13Z</dc:date>
    </item>
    <item>
      <title>Re: Best way to assign password to variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Best-way-to-assign-password-to-variable/m-p/690714#M210139</link>
      <description>&lt;P&gt;This is not an issue of the GETOPTION function, but a feature of encoded passwords.&lt;/P&gt;
&lt;P&gt;From the &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=proc&amp;amp;docsetTarget=p18zxcefav5k25n11ano9p2b71er.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;documentation of PROC PWENCODE&lt;/A&gt;&amp;nbsp;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"&lt;SPAN&gt;The encoded password is never written to the SAS log in plain text. Instead, each character of the password is replaced by an X in the SAS log."&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Oct 2020 18:45:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Best-way-to-assign-password-to-variable/m-p/690714#M210139</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-10T18:45:46Z</dc:date>
    </item>
    <item>
      <title>Re: Best way to assign password to variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Best-way-to-assign-password-to-variable/m-p/690715#M210140</link>
      <description>Yes, as I mentioned in my post that I have read the documentation and it’s working as expected.&lt;BR /&gt;&lt;BR /&gt;I’m seeking help for any alternative approach in this scenario.</description>
      <pubDate>Sat, 10 Oct 2020 18:49:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Best-way-to-assign-password-to-variable/m-p/690715#M210140</guid>
      <dc:creator>AnandVyas</dc:creator>
      <dc:date>2020-10-10T18:49:33Z</dc:date>
    </item>
    <item>
      <title>Re: Best way to assign password to variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Best-way-to-assign-password-to-variable/m-p/690716#M210141</link>
      <description>&lt;P&gt;There is no alternative approach. As soon as the log engine detects an encoded password, it replaces the characters with X's. You cannot PUT an encoded password to the log, for security reasons.&lt;/P&gt;</description>
      <pubDate>Sat, 10 Oct 2020 18:57:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Best-way-to-assign-password-to-variable/m-p/690716#M210141</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-10T18:57:09Z</dc:date>
    </item>
    <item>
      <title>Re: Best way to assign password to variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Best-way-to-assign-password-to-variable/m-p/690717#M210142</link>
      <description>&lt;P&gt;PS this means that the password is not&amp;nbsp;&lt;EM&gt;displayed&lt;/EM&gt;. To see if the encoded password is actually stored in the macro variable, try to use it as intended.&lt;/P&gt;</description>
      <pubDate>Sat, 10 Oct 2020 19:00:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Best-way-to-assign-password-to-variable/m-p/690717#M210142</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-10T19:00:49Z</dc:date>
    </item>
    <item>
      <title>Re: Best way to assign password to variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Best-way-to-assign-password-to-variable/m-p/690769#M210167</link>
      <description>&lt;P&gt;Yes, it doesn't work as intended.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options mprint mlogic;
%include "/mypath/test.sas";
%test;
%let username=%sysfunc(getoption(metauser));&lt;BR /&gt;%let pwd=%sysfunc(getoption(metapass));
%let host=mytestserver.com;
%let port=7980;
%let appserver=SASApp;

filename resp TEMP;
filename headers TEMP;

proc http method="POST" url="http://&amp;amp;host.:&amp;amp;port./SASLogon/v1/tickets" 
		in="username=&amp;amp;username.%nrstr(&amp;amp;password)=&amp;amp;pwd" headerout=headers out=resp 
		HEADEROUT_OVERWRITE;
run;

%global tgturl;

data _null_;
	infile headers termstr=CRLF length=c scanover truncover;
	input @'Location:' tgt $119.;
	put tgt=;
	call symput('tgturl', trim(tgt));
	%put &amp;amp;tgturl.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;104        %global tgturl;
 105        
 106        data _null_;
 107        infile headers termstr=CRLF length=c scanover truncover;
 108        input @'Location:' tgt $119.;
 109         put tgt=;
 110        call symput('tgturl', trim(tgt));
 111        %put &amp;amp;tgturl.;
  
 112        run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If I just hardcode the password, it works.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options mprint mlogic;
%include "/mypath/test.sas";
%test;
%let username=%sysfunc(getoption(metauser));
%let pwd={SAS002}FHIHJKLNAHIFGHRTY;
%let host=mytestserver.com;
%let port=7980;
%let appserver=SASApp;

/* Get a TGT and store the response and headers*/
filename resp TEMP;
filename headers TEMP;

proc http method="POST" url="http://&amp;amp;host.:&amp;amp;port./SASLogon/v1/tickets" 
		in="username=&amp;amp;username.%nrstr(&amp;amp;password)=&amp;amp;pwd" headerout=headers out=resp 
		HEADEROUT_OVERWRITE;
run;
%global tgturl;
data _null_;
	infile headers termstr=CRLF length=c scanover truncover;
	input @'Location:' tgt $119.;
	put tgt=;
	call symput('tgturl', trim(tgt));
	%put &amp;amp;tgturl.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
 tgt=http:/mytestserver.com:7980/SASLogon/v1/tickets/TGT-12345-hfkhlhlalkhkglajljlsdhalhlibalsdhlsajfiijalldanhiilandlanlsi
 NOTE: 1 record was read from the infile HEADERS.

 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       cpu time     &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 11 Oct 2020 07:23:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Best-way-to-assign-password-to-variable/m-p/690769#M210167</guid>
      <dc:creator>AnandVyas</dc:creator>
      <dc:date>2020-10-11T07:23:09Z</dc:date>
    </item>
    <item>
      <title>Re: Best way to assign password to variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Best-way-to-assign-password-to-variable/m-p/690771#M210168</link>
      <description>&lt;P&gt;I see; after reading the doc myself, it is clear that GETOPTION will not return the value from any option that contains a password.&lt;/P&gt;
&lt;P&gt;Which means that you have to find another way to supply the password to your code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you need to retrieve the password of a system user (one that can run a workspace server), then you won't find that in metadata anyway, as it (not the password, but the hash from it) is stored in the authentication source (local operating system or LDAP).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It seems you want to retrieve a ticket from the Logon Manager; what do you intend to do with that?&lt;/P&gt;</description>
      <pubDate>Sun, 11 Oct 2020 09:00:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Best-way-to-assign-password-to-variable/m-p/690771#M210168</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-11T09:00:13Z</dc:date>
    </item>
    <item>
      <title>Re: Best way to assign password to variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Best-way-to-assign-password-to-variable/m-p/690791#M210175</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;. I fetched the pass directly from file and it worked.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options mprint mlogic;
%include "/mypath/test.sas";
%test;
%let username=%sysfunc(getoption(metauser));
filename env '/mypath/test.sas';

data _null_;
	infile env termstr=CRLF length=c scanover truncover;
	input @'metapass=' pass $50.;
	quote1=find(pass, '"');
	quote2=find(pass, '";');
	pass=substr(pass, quote1+1, quote2-2);
	call symput('pwd', pass);
run;

%let host=mytestserver.com;
%let port=7980;
%let appserver=SASApp;

/* Get a TGT and store the response and headers*/
filename resp TEMP;
filename headers TEMP;

proc http method="POST" url="http://&amp;amp;host.:&amp;amp;port./SASLogon/v1/tickets" 
		in="username=&amp;amp;username.%nrstr(&amp;amp;password)=&amp;amp;pwd" headerout=headers out=resp 
		HEADEROUT_OVERWRITE;
run;

%global tgturl;

data _null_;
	infile headers termstr=CRLF length=c scanover truncover;
	input @'Location:' tgt $119.;
	put tgt=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Log:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;tgt=http:/mytestserver.com:7980/SASLogon/v1/tickets/TGT-12345-hfkhlhlalkhkglajljlsdhalhlibalsdhlsajfiijalldanhiilandlanlsi
 NOTE: 1 record was read from the infile HEADERS.

 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       cpu time    &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 11 Oct 2020 14:27:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Best-way-to-assign-password-to-variable/m-p/690791#M210175</guid>
      <dc:creator>AnandVyas</dc:creator>
      <dc:date>2020-10-11T14:27:45Z</dc:date>
    </item>
    <item>
      <title>Re: Best way to assign password to variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Best-way-to-assign-password-to-variable/m-p/690810#M210184</link>
      <description>&lt;P&gt;A quick note on your code.&amp;nbsp; You probably do NOT want to store trailing spaces into your macro variable by using the older CALL SYMPUT() function instead of the newer more powerful CALL SYMPUTX() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	call symputX('pwd', pass);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 11 Oct 2020 18:39:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Best-way-to-assign-password-to-variable/m-p/690810#M210184</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-10-11T18:39:06Z</dc:date>
    </item>
  </channel>
</rss>

