我上的C#和ASP.Net應用程序的工作,使用窗體身份驗證,我發現這裏... http://msdn.microsoft.com/en-us/library/ms180890(v=vs.90).aspx如何拉電子郵件從LDAP到Web應用程序
它的偉大工程,但現在我想去小有一點進一步,也拉,從郵件領域的電子郵件地址,LDAP和管道到一個文本用的
lblName.Text = "Hello " + Context.User.Identity.Name + ".";
lblAuthType.Text = "You were authenticated using "
+ Context.User.Identity.AuthenticationType + ".";
我搜索了休息和閱讀論文鏈接LO歐凱一個答案......
How to get the current user's Active Directory details in C#
How to use email as httpcontext.User.Identity.name
http://www.codekeep.net/snippets/402e4677-f8d0-419c-b656-b3c28e740296.aspx
從我可以告訴我需要將代碼添加到LdapAuthentication.cs像其他的DirectorySearcher查詢,但我必須做一個全新的搜索,或者我可以將它添加到它查詢用戶名時查詢?像
DirectorySearcher search = new DirectorySearcher(entry);
search.Filter = "(SAMAccountName=" + username + ")";
search.PropertiesToLoad.Add("cn");
search.PropertiesToLoad.Add("mail"); // e-mail address
SearchResult result = search.FindOne();
if (null == result)
{
return false;
}
..I'm所以新來這和我如此努力,但我不能讓這個..任何幫助嗎?