How to get LDAP displayname and email id using Msbuild?

2k Views Asked by At

I got communitytasks to send mail. But in subject itself if i add display name of LDAP user, I would know who is taking build.

Following Code in Powershell would give me mail id and displayname

    $searcher = [adsisearcher]"(samaccountname=$env:USERNAME)"
    $mailid= $searcher.FindOne().Properties.mail
    $DispName= $searcher.FindOne().Properties.displayname

Is there any way to get mail id and displayname in Msbuild or is it better to call powershell commands through inline task?

1

There are 1 best solutions below

1
On

In MSBuild you can refer to environment variables as if they were defined properties, so taking the name of the user is as simple as writing $(USERNAME).