Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to obtain email address with window authentication

I am designing a web application using the ASP.net MVC framework. I would like to use Windows Authentication and do Role Checks using the Role Manager SQLRoleProvider.

How can I determine the email address of the current logged on user? Is this even possible?

The application will be deployed in a multi-domain intranet, if that matters (which I assume it does).

Thanks for any help!

like image 532
carter Avatar asked Oct 28 '09 17:10

carter


1 Answers

Here is a sample from some code:

DirectorySearcher searcher = new DirectorySearcher();    
searcher.Filter = string.Format("sAMAccountName={0}", _name);    
SearchResult user = searcher.FindOne();    
string emailAddr = user.Properties["mail"][0].ToString();
like image 55
Mark Kadlec Avatar answered Oct 03 '22 20:10

Mark Kadlec