Hey,
maybe there are more elegant ways but I needed to retrieve email address from owner to be able to send email notifications.
I sent the samAccountName to a powershell host who retrieved and returned email address
the biggest problem here is actually to parse the result (powershell host sends object, not only the string with email address)
this is what I cooked up to parse the object and retrive the string from powershell host (heartbreaking)
===
jsonres=outputPS.getAsJson();
System.log("XML response:\n"+jsonres+"\n");
j2=JSON.parse(jsonres);
ReturnParameter=j2.Objs.Obj.LST.Obj[1].S;
System.log(returnParameter)
===
Powershell code (yes -- its obvious -- i'm not a programmer) you can modify the filter is you feed samaccountname
## Accepts UPN as parameter and returns emailaddress
param(
[string] $userPrincipalName
)
[string] $emailAddress
Import-Module activedirectory
$filter= "userPrincipalName -eq '"+$userPrincipalName+"'"
$mailAddress= get-aduser -filter $filter -server <myGlobalCatalogServer>:3268 -properties emailaddress
$emailAddress= $mailAddress.EmailAddress
return $emailAddress