views:

66

answers:

3

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!

+1  A: 

You can look up the user's properties in Active Directory. Here is a great article that explains how to do that using System.DirectoryServices and C#:

http://www.codeproject.com/KB/system/getuserfrmactdircsharp.aspx

TimS
A: 

The asp.net membership services database is just a database, which you can execute a query against directly. I dont think the default membership provider has a way to get the email address however.

NickLarsen
+1  A: 

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();
Mark Kadlec