Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
943 views
in Technique[技术] by (71.8m points)

asp.net - 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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...