tie membership login to my table?

G

Guest

I need to have users login using the ASP.NET sqlprovider but then would like
to direct them to a page based on some info in a separate table. Is there
code to generate the strange userid field in the membership table so I can
assign the userid to my table column and then search for my table row using
this user id?

Any other suggestions (besides writing a custom provider which I haven't the
time for) on how to achieve this linkage?

Thanks much
 
K

Ken Cox [Microsoft MVP]

There's a built-in view (vw_aspnet_Users ) where you can get the UserId by
passing the username (which you have from the loginname control).

Here's the idea:

<%@ Page Language="VB" %>
<%@ import namespace="System.Data" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Get the UserID from ASPNET users database</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<p>
<asp:listbox id="ListBox1" runat="server"
datasourceid="SqlDataSource1" datatextfield="Uid"></asp:listbox></p>
<asp:sqldatasource id="SqlDataSource1" runat="server"
connectionstring="<%$ ConnectionStrings:ASPNETDBConnectionString %>"
selectcommand="SELECT UserId AS Uid FROM vw_aspnet_Users WHERE (UserName =
'kencox')"></asp:sqldatasource>
&nbsp;</div>
</form>
</body>
</html>


<connectionStrings>
<add name="ASPNETDBConnectionString" connectionString="Data
Source=.\SQLEXPRESS;AttachDbFilename=&quot;profilesite\App_Data\ASPNETDB.MDF&quot;;Integrated
Security=True;Connect Timeout=30;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>

Let us know if this helps?

(BTW, I wrote the Profile and Membership chapters for ASP.NET 2.0 All-In-One
Desk Reference For Dummies
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0471785989.html )


Ken
Microsoft MVP [ASP.NET]
 
G

Guest

Ken, thanks much, this is just the ticket I was looking for!

Ken Cox said:
There's a built-in view (vw_aspnet_Users ) where you can get the UserId by
passing the username (which you have from the loginname control).

Here's the idea:

<%@ Page Language="VB" %>
<%@ import namespace="System.Data" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Get the UserID from ASPNET users database</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<p>
<asp:listbox id="ListBox1" runat="server"
datasourceid="SqlDataSource1" datatextfield="Uid"></asp:listbox></p>
<asp:sqldatasource id="SqlDataSource1" runat="server"
connectionstring="<%$ ConnectionStrings:ASPNETDBConnectionString %>"
selectcommand="SELECT UserId AS Uid FROM vw_aspnet_Users WHERE (UserName =
'kencox')"></asp:sqldatasource>
</div>
</form>
</body>
</html>


<connectionStrings>
<add name="ASPNETDBConnectionString" connectionString="Data
Source=.\SQLEXPRESS;AttachDbFilename="profilesite\App_Data\ASPNETDB.MDF";Integrated
Security=True;Connect Timeout=30;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>

Let us know if this helps?

(BTW, I wrote the Profile and Membership chapters for ASP.NET 2.0 All-In-One
Desk Reference For Dummies
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0471785989.html )


Ken
Microsoft MVP [ASP.NET]


Dabbler said:
I need to have users login using the ASP.NET sqlprovider but then would
like
to direct them to a page based on some info in a separate table. Is there
code to generate the strange userid field in the membership table so I can
assign the userid to my table column and then search for my table row
using
this user id?

Any other suggestions (besides writing a custom provider which I haven't
the
time for) on how to achieve this linkage?

Thanks much
 
K

Ken Cox [Microsoft MVP]

Thanks for letting us know it worked!

Dabbler said:
Ken, thanks much, this is just the ticket I was looking for!

Ken Cox said:
There's a built-in view (vw_aspnet_Users ) where you can get the UserId
by
passing the username (which you have from the loginname control).

Here's the idea:

<%@ Page Language="VB" %>
<%@ import namespace="System.Data" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Get the UserID from ASPNET users database</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<p>
<asp:listbox id="ListBox1" runat="server"
datasourceid="SqlDataSource1" datatextfield="Uid"></asp:listbox></p>
<asp:sqldatasource id="SqlDataSource1" runat="server"
connectionstring="<%$ ConnectionStrings:ASPNETDBConnectionString %>"
selectcommand="SELECT UserId AS Uid FROM vw_aspnet_Users WHERE (UserName
=
'kencox')"></asp:sqldatasource>
</div>
</form>
</body>
</html>


<connectionStrings>
<add name="ASPNETDBConnectionString" connectionString="Data
Source=.\SQLEXPRESS;AttachDbFilename="profilesite\App_Data\ASPNETDB.MDF";Integrated
Security=True;Connect Timeout=30;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>

Let us know if this helps?

(BTW, I wrote the Profile and Membership chapters for ASP.NET 2.0
All-In-One
Desk Reference For Dummies
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0471785989.html )


Ken
Microsoft MVP [ASP.NET]


Dabbler said:
I need to have users login using the ASP.NET sqlprovider but then would
like
to direct them to a page based on some info in a separate table. Is
there
code to generate the strange userid field in the membership table so I
can
assign the userid to my table column and then search for my table row
using
this user id?

Any other suggestions (besides writing a custom provider which I
haven't
the
time for) on how to achieve this linkage?

Thanks much
 

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

Top