Last post Nov 20, 2019 02:35 PM by PatriceSc
Nov 20, 2019 02:10 AM|johnzee|LINK
I need to return the email addresses of users and email them a newsletter. I would have a user's name in the format of first and last only. Note these users won't be logged in to the application so I can't use httpcontext.user.identity etc. I will just
have a list of user names like John Smith, Jane Doe and I would like to pass them to AD or claims and return their valid email addresses. The application admin will manage users and always supply the first and last names only. I am trying to make their job
easier by not asking for the email addresses and would like to accomplish it via code. I tried to just take the first and last name and concatenate it with my company's domain .com but due to inconsistent email formats simple concatenation is not working
right. All the examples I found to return attributes from AD or claims are only for the current logged in user.
If there is a way to accomplish this task then please let me know.
Nov 20, 2019 02:19 PM|mgebhard|LINK
You need the email address or a way to lookup the email address.
Nov 20, 2019 02:35 PM|PatriceSc|LINK
You can query AD using https://docs.microsoft.com/en-us/dotnet/api/system.directoryservices.accountmanagement.userprincipal.findbyidentity?view=netframework-4.8 or https://philipm.at/2018/searching_users_in_active_directory.html if
you need more flexibility (first sample).