By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,984 Members | 2,794 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,984 IT Pros & Developers. It's quick & easy.

q: user e-mail

P: n/a
Hello,
User.Identity.Name gives me current user name, how can I get the e-mail
address of current user?
Jim.

Nov 19 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"JIM.H." <JI**@discussions.microsoft.com> wrote in message
news:9E**********************************@microsof t.com...
Hello,
User.Identity.Name gives me current user name, how can I get the e-mail
address of current user?
Jim.

Nov 19 '05 #2

P: n/a
If you are in that environment as Steve adviced then you should be able
to retrieve the email addy!
Patrick
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #3

P: n/a
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?
"Patrick Olurotimi Ige" wrote:
If you are in that environment as Steve adviced then you should be able
to retrieve the email addy!
Patrick
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 19 '05 #4

P: n/a
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);

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net

"JIM.H." <JI**@discussions.microsoft.com> wrote in message
news:C1**********************************@microsof t.com...
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?
"Patrick Olurotimi Ige" wrote:
If you are in that environment as Steve adviced then you should be able
to retrieve the email addy!
Patrick
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.