public void TestMethod3()
 {
     WindowsIdentity wi = WindowsIdentity.GetCurrent();
     Assert.IsNotNull(wi);
     AdSearch adSearch = new AdSearch(AdSearch.GetDomainFromUserAccount(wi.Name));
     Assert.IsNotNull(adSearch.FindEmail(wi.Name));
 }
 private string GetEmailAddress(JobExecutionContext context, WindowsIdentity windowsIdentity)
 {
    JobDataMap jobDataMap = context.MergedJobDataMap;
    string email;
    if (jobDataMap.Contains(KeyEmail))
    {
        email = Convert.ToString(jobDataMap[KeyEmail]);
    }
    else
    {
       AdSearch adSearch = new AdSearch(AdSearch.GetDomainFromUserAccount(windowsIdentity.Name));
       email = adSearch.FindEmail(AdSearch.GetAccountNameFromUserAccount(windowsIdentity.Name));
    }
    return email;
 }