providerUserKey ASP.NET Membershipp

D

Davie

I am implementing a Custom Provider for ASP.NET 2.0 membership. When I come
to write the
public override MembershipUser CreateUser(string username, string password,
string email, string passwordQuestion, string passwordAnswer, bool
isApproved, object providerUserKey, out MembershipCreateStatus status)

{

throw new Exception("The method or operation is not implemented.");


}



What do I do with the providerUserKey object?? I know it is used for a key,
but I am unsure what i use it for?

If there is a proper implementation for SQL Providers I would much
appreciate it if you could point me in the right direction. I've seen a lot
of half baked solutions which don't work out there.

Many thanks.
 
B

Brock Allen

The providerUserKey is a provider specific ID for the user. The problem is
that you may have 2 diff applications configured to use the same provider
and the same DB, and you may get 2 diff users in those 2 diff apps with the
same username. Those are diff users, so you need a way to distinguish between
them. So, use an identity column :)
 
S

Steven Cheng[MSFT]

Thanks for Brock's informative inputs.

Hi Davie,

As Brock has mentioned, the providerUserKey is just a idenitifier for the
membership user record. More exactly, it's just like a PK value for that
user record. For distinguish users with same username in different
application, most providers will use an "ApplicationName" pareameter (not
this providerUserKey) which could be generated from your asp.net
application's name. For example, the SqlMemberShipProvider just implement
as this, it use a "ApplicationName" parameter field in table to distinguish
users between applications. and the providerUserKey is expected as a Guid
object for identifying each user record.

Also, when we implementing our own custom membershipProvider, whether to
pass this field all depend on your database structure or storage details.
For example, if your underlying user datatable has an Autogenerated primary
key column, we don't need to force the application (consumer) to manually
pass in this providerUserKey. We just let the database to autogenerated ID
and return it to the consumer (through the returned MemberShipUser) after
completing the create operation. BTW, if you have interests, you can use
the reflector tool to have a look at the buildin SqlMemberShipProvider's
code which may give you some ideas on it.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| Message-ID: <[email protected]>
| From: Brock Allen <[email protected]>
| Subject: Re: providerUserKey ASP.NET Membershipp
| References: <[email protected]>
| Mime-Version: 1.0
| Content-Transfer-Encoding: 8bit
| Content-Type: text/plain; charset=iso-8859-1; format=flowed
| X-Newsreader: JetBrains Omea Reader 469.1
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Date: Thu, 01 Sep 2005 18:55:13 -0700
| NNTP-Posting-Host: 12.162.27.25
| Lines: 1
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:121888
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| The providerUserKey is a provider specific ID for the user. The problem
is
| that you may have 2 diff applications configured to use the same provider
| and the same DB, and you may get 2 diff users in those 2 diff apps with
the
| same username. Those are diff users, so you need a way to distinguish
between
| them. So, use an identity column :)
|
| -Brock
| DevelopMentor
| http://staff.develop.com/ballen
|
|
|
| > I am implementing a Custom Provider for ASP.NET 2.0 membership. When
| > I come
| > to write the
| > public override MembershipUser CreateUser(string username, string
| > password,
| > string email, string passwordQuestion, string passwordAnswer, bool
| > isApproved, object providerUserKey, out MembershipCreateStatus status)
| > {
| >
| > throw new Exception("The method or operation is not implemented.");
| >
| > }
| >
| > What do I do with the providerUserKey object?? I know it is used for
| > a key, but I am unsure what i use it for?
| >
| > If there is a proper implementation for SQL Providers I would much
| > appreciate it if you could point me in the right direction. I've seen
| > a lot of half baked solutions which don't work out there.
| >
| > Many thanks.
| >
|

|
|
 
D

Davie

Thanks very much. This is much appreciated.


Steven Cheng said:
Thanks for Brock's informative inputs.

Hi Davie,

As Brock has mentioned, the providerUserKey is just a idenitifier for the
membership user record. More exactly, it's just like a PK value for that
user record. For distinguish users with same username in different
application, most providers will use an "ApplicationName" pareameter (not
this providerUserKey) which could be generated from your asp.net
application's name. For example, the SqlMemberShipProvider just implement
as this, it use a "ApplicationName" parameter field in table to
distinguish
users between applications. and the providerUserKey is expected as a Guid
object for identifying each user record.

Also, when we implementing our own custom membershipProvider, whether to
pass this field all depend on your database structure or storage details.
For example, if your underlying user datatable has an Autogenerated
primary
key column, we don't need to force the application (consumer) to manually
pass in this providerUserKey. We just let the database to autogenerated ID
and return it to the consumer (through the returned MemberShipUser) after
completing the create operation. BTW, if you have interests, you can use
the reflector tool to have a look at the buildin SqlMemberShipProvider's
code which may give you some ideas on it.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| Message-ID: <[email protected]>
| From: Brock Allen <[email protected]>
| Subject: Re: providerUserKey ASP.NET Membershipp
| References: <[email protected]>
| Mime-Version: 1.0
| Content-Transfer-Encoding: 8bit
| Content-Type: text/plain; charset=iso-8859-1; format=flowed
| X-Newsreader: JetBrains Omea Reader 469.1
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| Date: Thu, 01 Sep 2005 18:55:13 -0700
| NNTP-Posting-Host: 12.162.27.25
| Lines: 1
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:121888
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| The providerUserKey is a provider specific ID for the user. The problem
is
| that you may have 2 diff applications configured to use the same
provider
| and the same DB, and you may get 2 diff users in those 2 diff apps with
the
| same username. Those are diff users, so you need a way to distinguish
between
| them. So, use an identity column :)
|
| -Brock
| DevelopMentor
| http://staff.develop.com/ballen
|
|
|
| > I am implementing a Custom Provider for ASP.NET 2.0 membership. When
| > I come
| > to write the
| > public override MembershipUser CreateUser(string username, string
| > password,
| > string email, string passwordQuestion, string passwordAnswer, bool
| > isApproved, object providerUserKey, out MembershipCreateStatus status)
| > {
| >
| > throw new Exception("The method or operation is not implemented.");
| >
| > }
| >
| > What do I do with the providerUserKey object?? I know it is used for
| > a key, but I am unsure what i use it for?
| >
| > If there is a proper implementation for SQL Providers I would much
| > appreciate it if you could point me in the right direction. I've seen
| > a lot of half baked solutions which don't work out there.
| >
| > Many thanks.
| >
|

|
|
 
S

Steven Cheng[MSFT]

You're welcome Davie,

Have a good weekend!

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| From: "Davie" <[email protected]>
| References: <[email protected]>
<[email protected]>
<[email protected]>
| Subject: Re: providerUserKey ASP.NET Membershipp
| Date: Fri, 2 Sep 2005 09:04:55 +0100
| Lines: 102
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
| X-RFC2646: Format=Flowed; Original
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: 82-41-9-147.cable.ubr02.edin.blueyonder.co.uk
82.41.9.147
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:121937
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Thanks very much. This is much appreciated.
|
|
| | > Thanks for Brock's informative inputs.
| >
| > Hi Davie,
| >
| > As Brock has mentioned, the providerUserKey is just a idenitifier for
the
| > membership user record. More exactly, it's just like a PK value for that
| > user record. For distinguish users with same username in different
| > application, most providers will use an "ApplicationName" pareameter
(not
| > this providerUserKey) which could be generated from your asp.net
| > application's name. For example, the SqlMemberShipProvider just
implement
| > as this, it use a "ApplicationName" parameter field in table to
| > distinguish
| > users between applications. and the providerUserKey is expected as a
Guid
| > object for identifying each user record.
| >
| > Also, when we implementing our own custom membershipProvider, whether to
| > pass this field all depend on your database structure or storage
details.
| > For example, if your underlying user datatable has an Autogenerated
| > primary
| > key column, we don't need to force the application (consumer) to
manually
| > pass in this providerUserKey. We just let the database to autogenerated
ID
| > and return it to the consumer (through the returned MemberShipUser)
after
| > completing the create operation. BTW, if you have interests, you can
use
| > the reflector tool to have a look at the buildin
SqlMemberShipProvider's
| > code which may give you some ideas on it.
| >
| > Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| > --------------------
| > | Message-ID: <[email protected]>
| > | From: Brock Allen <[email protected]>
| > | Subject: Re: providerUserKey ASP.NET Membershipp
| > | References: <[email protected]>
| > | Mime-Version: 1.0
| > | Content-Transfer-Encoding: 8bit
| > | Content-Type: text/plain; charset=iso-8859-1; format=flowed
| > | X-Newsreader: JetBrains Omea Reader 469.1
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet
| > | Date: Thu, 01 Sep 2005 18:55:13 -0700
| > | NNTP-Posting-Host: 12.162.27.25
| > | Lines: 1
| > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
| > | Xref: TK2MSFTNGXA01.phx.gbl
| > microsoft.public.dotnet.framework.aspnet:121888
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| > |
| > | The providerUserKey is a provider specific ID for the user. The
problem
| > is
| > | that you may have 2 diff applications configured to use the same
| > provider
| > | and the same DB, and you may get 2 diff users in those 2 diff apps
with
| > the
| > | same username. Those are diff users, so you need a way to distinguish
| > between
| > | them. So, use an identity column :)
| > |
| > | -Brock
| > | DevelopMentor
| > | http://staff.develop.com/ballen
| > |
| > |
| > |
| > | > I am implementing a Custom Provider for ASP.NET 2.0 membership.
When
| > | > I come
| > | > to write the
| > | > public override MembershipUser CreateUser(string username, string
| > | > password,
| > | > string email, string passwordQuestion, string passwordAnswer, bool
| > | > isApproved, object providerUserKey, out MembershipCreateStatus
status)
| > | > {
| > | >
| > | > throw new Exception("The method or operation is not implemented.");
| > | >
| > | > }
| > | >
| > | > What do I do with the providerUserKey object?? I know it is used
for
| > | > a key, but I am unsure what i use it for?
| > | >
| > | > If there is a proper implementation for SQL Providers I would much
| > | > appreciate it if you could point me in the right direction. I've
seen
| > | > a lot of half baked solutions which don't work out there.
| > | >
| > | > Many thanks.
| > | >
| > |
| >
| > |
| > |
| >
|
|
|
 
A

Alvin Bruney - ASP.NET MVP

Brock,
shoot me an email please - (e-mail address removed)

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET
 
D

Davie

Thanks Guys, Problem sorted.

Much appreciated.


Alvin Bruney - ASP.NET MVP said:
Brock,
shoot me an email please - (e-mail address removed)

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET
-------------------------------------------------------



Brock Allen said:
The providerUserKey is a provider specific ID for the user. The problem
is
that you may have 2 diff applications configured to use the same provider
and the same DB, and you may get 2 diff users in those 2 diff apps with the
same username. Those are diff users, so you need a way to distinguish between
them. So, use an identity column :)
 

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,968
Messages
2,570,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top