Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP.NET 2.0 Membership Current User

Reply
Thread Tools

ASP.NET 2.0 Membership Current User

 
 
Ray Booysen
Guest
Posts: n/a
 
      05-05-2006
Hi all

I'm wanting to know if its possible to retrieve the current user when
using the 2.0 membership provider. The GUID UserID in Users I am using
as a foreign key in other tables and I need to use it for other database
operations.

The membership class doesn't expose a CurrentUser() method and has Find
methods but not something I can use.

Any ideas?

Regards
Ray
 
Reply With Quote
 
 
 
 
=?Utf-8?B?YnJpYW5zW01DU0Rd?=
Guest
Posts: n/a
 
      05-05-2006
Hello Ray,

The membership class exposes GetUser() not CurrentUser(). You should be able
to use the Membership.GetUser() method to get the current user:

MembershipUser u = Membership.GetUser(HttpContext.Current.User.Identi ty.Name);
if (u != null)
{
// do some work
}
--
brians
http://www.limbertech.com


"Ray Booysen" wrote:

> Hi all
>
> I'm wanting to know if its possible to retrieve the current user when
> using the 2.0 membership provider. The GUID UserID in Users I am using
> as a foreign key in other tables and I need to use it for other database
> operations.
>
> The membership class doesn't expose a CurrentUser() method and has Find
> methods but not something I can use.
>
> Any ideas?
>
> Regards
> Ray
>

 
Reply With Quote
 
Ray Booysen
Guest
Posts: n/a
 
      05-06-2006
brians[MCSD] wrote:
> Hello Ray,
>
> The membership class exposes GetUser() not CurrentUser(). You should be able
> to use the Membership.GetUser() method to get the current user:
>
> MembershipUser u = Membership.GetUser(HttpContext.Current.User.Identi ty.Name);
> if (u != null)
> {
> // do some work
> }

Great. Thanks for the help.

Regards
Ray
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Catching user switching and getting current active user from rooton linux mpnordland Python 0 12-20-2010 04:54 PM
People Smarter Than: Big-8 Management Board - Current Membership & Composition Aratzio Computer Support 4 03-28-2010 02:10 AM
Membership.GetUser() vs HttpContext.Current.User Jeff ASP .Net 0 10-19-2008 09:37 PM
HttpContext.Current.User returns null (forms authentification); how to use custom role and membership providers together? alexandis@gmail.com ASP .Net 4 11-01-2007 08:56 AM
trying to spawn a process (say an exe file) with different user crendentials than that of the current user but getting 1314 error ranju C++ 1 05-18-2007 02:35 AM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57