q: user e-mail

G

Guest

Hello,
User.Identity.Name gives me current user name, how can I get the e-mail
address of current user?
Jim.
 
S

Steve C. Orr [MVP, MCSD]

Unless you're using Windows Authentication and Active Directory in an
Intranet environment, there is no way to get the user's email address except
asking them for it.
 
P

Patrick Olurotimi Ige

If you are in that environment as Steve adviced then you should be able
to retrieve the email addy!
Patrick
 
G

Guest

Application is fro intranet. If I am able to get current user with
User.Identity.Name, doen't that mean I am using Windows Authentication? If
not, what shoudl I do and how should I retreive e-mail from AD?
 
S

Steve C. Orr [MVP, MCSD]

This code should get you the user's full name.
With a little tinkering I bet you can also get the email address.
(also set <identity impersonate="true"/> in your web.config)


string Domain_Slash_User = Context.User.Identity.Name;


Domain_Slash_Machine = Domain_Slash_Machine.Replace(@"\", @"/");string
queryString = @"WinNT://" + Domain_Slash_Machine;DirectoryEntry obDirEntry =
new DirectoryEntry(queryString);
System.DirectoryServices.PropertyCollection coll = obDirEntry.Properties;



object obVal = coll["FullName"].Value;_User = obVal.ToString();

Session.Add("UserFullName", _User);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top