BookmarkSubscribeRSS Feed
Aditi24
Obsidian | Level 7

Hi, 

I want to identify the mail ID from windows username in SAS. In .NET I have the code for same as below:-

System.DirectoryServices.AccountManagement.UserPrincipal.Current.EmailAddress()

 

But I am not able to find any solution in SAS. Please help!

Thanks.

3 REPLIES 3
Kurt_Bremser
Super User

I'd suggest to write a little .NET program that makes that method/function call and writes the result to standard output.

Then call that program from SAS with

filename oscmd pipe "your_net_program";
data _null_;
infile oscmd;
input;
call symput('current_email',_infile_);
run;
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Assuming you have priviledge to access Active Directory properties then DSGET/DSQUERY:

https://technet.microsoft.com/en-us/library/cc732535(v=ws.11).aspx

 

Some examples:

https://social.technet.microsoft.com/Forums/windowsserver/en-US/c5f5e0b6-7fe3-4c80-8d9b-972252e9552f...

http://serverfault.com/questions/27223/command-line-active-directory-query-email-address-for-usernam...

 

However I would point out that SAS is built to do analysis and processing of data, not for doing administrative tasks on your operating systems, so it sounds like your doing something wrong.  I presume if you are after email then your sending something to someone?  If so then there are far better methods out there - shared network area, sharepoint, report publishing platforms etc.  Sending things via email can be unsecure, and there are limits on what you can send.

 

 

jrsousa2
Obsidian | Level 7

However I would point out that SAS is built to do analysis and processing of data, not for doing administrative tasks on your operating systems, so it sounds like your doing something wrong.  I presume if you are after email then your sending something to someone?

 

There are a million reasons why someone would want to send an email thru SAS. That's why he's searching for a way to find out the email given a userid. For example, it's useful for alerts. Attachments are useful to send from SAS as well, with the outputs or the logs of a job just so some key people are informed of the results of a process and if there was failure or what not.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1335 views
  • 1 like
  • 4 in conversation