I am working on an C# and ASP.Net application, that uses Forms Authentication that I found here... http://msdn.microsoft.com/en-us/library/ms180890(v=vs.90).aspx
It works great but now I would like to go alittle further and also pull the email address from the mail field in LDAP and pipe it to a text with the rest of the
lblName.Text = "Hello " + Context.User.Identity.Name + ".";
lblAuthType.Text = "You were authenticated using "
+ Context.User.Identity.AuthenticationType + ".";
I searched and read theses links looking for an answer...
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
from what I can tell I need to add code to the LdapAuthentication.cs like another DirectorySearcher query but do I have to make a totally new search or can I just add it to the query it makes when it looks up the usersname?? Like
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 so new to this and I'm trying so hard but I can't get this.. any help?