Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old August 2nd, 2006, 08:06 AM
Authorized User
 
Join Date: Aug 2006
Location: Mostar, HNK, Bosnia and Herzegovina.
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to hcusto
Default I need suggestion about user accounts

Hi,
I am working for a few years as php/mysql programmer, and becouse of my new work I need to use .NET.

So I am learning C# and learning to use Visual studio.

Right now i am in doubt what should I use (should I create my custom Membership Provider, or create tables (useres,roles) with my required fields and create functions which will check is password provided during the login correct and similar)

Reasons why i am not using login controls is this (I don't know is my reason reasonable becouse I am new to all this stuff)

1. Now we are working on SQL Express database, but at the end of the project, we will use Oracle DB.

2. Tables which I get when I run file(I don't know the name of file, but it is in DOT Net Framework folder and it creates tables in databese for using SQLExpress membership provider, it's some exe file) and it creates a lot of tables which I don't want to use, i need only Users, Roles tables.

3. I must save more informations then I can right now (the columns that i need (like: Newsletter, SpecialOffers etc ) don't exists in tables)

So please give me some suggestions what should i do.

Best regards,
Haris

Reply With Quote
  #2 (permalink)  
Old August 5th, 2006, 12:42 PM
Authorized User
 
Join Date: Aug 2006
Location: Mostar, HNK, Bosnia and Herzegovina.
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to hcusto
Default

No one can help me ?

Reply With Quote
  #3 (permalink)  
Old August 6th, 2006, 04:34 AM
Imar's Avatar
Wrox Author
Points: 65,739, Level: 100
Points: 65,739, Level: 100 Points: 65,739, Level: 100 Points: 65,739, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 15,978
Thanks: 64
Thanked 1,350 Times in 1,330 Posts
Default

Hi there,

First of all, when you run aspnet_regsql it does indeed create a lot of tables by default. However, if you run the tool from a command line, you can specify what features you want to support. Type aspnet_regsql /? for more info.

I don't think it's a good idea to work with SQL Express now if your intention is to switch to Oracle. I think you'll run into a lot of problems with incompatible code when you make the switch.

Writing your own provider is not that hard. And the main benefit of your own provider is that you can easily rewrite the code so it works with Oracle. Take a look here for some suggestions about creating your own provider:

http://Imar.Spaanjaars.Com/QuickDocId.aspx?quickdoc=380

I am not sure, but I wouldn't be surprised if there were already Oracle providers.

If you want to store some additional info besides the (default) user tables, maybe this helps:

http://weblogs.asp.net/scottgu/archi...18/427754.aspx

With this solution, you can use the standard Login features offered by .NET 2.0 and store additional info in the Profile object.

However, all of this will only work out of the box with a SQL Server database, not with Oracle.

Hope this helps,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
Reply With Quote
  #4 (permalink)  
Old August 8th, 2006, 04:07 AM
Authorized User
 
Join Date: Aug 2006
Location: Mostar, HNK, Bosnia and Herzegovina.
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to hcusto
Default

Thnx for your help, i will try to create custom membership provider.

Becouse I am new to all of this stuff about provider model, i have a couple of questions.

1. Where is stored profile data (becouse there are no rows in the table users for profile data)

2. How can i have a list of all users which have same let say country

3. I want to create my login form, i don't want to use "Login Control". How can i solve that

Thanx in advance.
Haris

Reply With Quote
  #5 (permalink)  
Old August 8th, 2006, 04:18 AM
Imar's Avatar
Wrox Author
Points: 65,739, Level: 100
Points: 65,739, Level: 100 Points: 65,739, Level: 100 Points: 65,739, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 15,978
Thanks: 64
Thanked 1,350 Times in 1,330 Posts
Default

Quote:
quote:3. I want to create my login form, i don't want to use "Login Control". How can i solve that
In that case, why bother with a custom provider? Why don't you write your own logic to validate users? The whole idea about a provider (custom or out-of-the-box) is that you can use controls like Login without any additional code. If you don't want to use those controls, I don't see much point in writing a provider.

Quote:
quote:1. Where is stored profile data (becouse there are no rows in the table users for profile data)
Normally, it's stored in the aspnet_Profiles table in your database.

Quote:
quote:2. How can i have a list of all users which have same let say country
This is not something the provider model offers out of the box. You can write the required functionality yourself, and expose it as additional members on your custom providers (e.g. FindUsersByCountry, similar to FindUsersByEmail), or if you don't write a provider through a custom class / API.

Cheers,

Imar
Reply With Quote
  #6 (permalink)  
Old August 9th, 2006, 03:15 AM
Authorized User
 
Join Date: Aug 2006
Location: Mostar, HNK, Bosnia and Herzegovina.
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to hcusto
Default

Honestly, I don't know on which way to do this. So i have posted my question here.

Before when i was using php/mysql i have to create everything, and i have don'e that.

Now, becouse i am new to asp.net i asked you what to do. Should i use the same way as I do with php/mysql (creating everything) or should i use User Profiles in .net


Reply With Quote
  #7 (permalink)  
Old August 10th, 2006, 01:34 AM
Imar's Avatar
Wrox Author
Points: 65,739, Level: 100
Points: 65,739, Level: 100 Points: 65,739, Level: 100 Points: 65,739, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 15,978
Thanks: 64
Thanked 1,350 Times in 1,330 Posts
Default

Hi again,

The answer is of course: it depends.... ;)

Personally, I would use the new Login controls and provider model. These features add a lot of functionality without requiring any custom code.

However, you seemed to have made up your mind already:
Quote:
quote:I want to create my login form, i don't want to use "Login Control".
Is there a reason you don't want to use these controls? They are highly customizable (for example, you can control the entire HTML they render) and can save you a lot of work.

If you don't want to use these controls and don't want to use the provider model, indeed the way to go is how you did it earlier: create your own form, gather user details, submit them to a database and validate the user.

Personally, I would investigate the out-of-the-box features of ASP.NET 2 once more and see if they are useful to you. Might save you from a lot of work.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
Reply With Quote
  #8 (permalink)  
Old August 18th, 2006, 04:07 AM
Authorized User
 
Join Date: Aug 2006
Location: Mostar, HNK, Bosnia and Herzegovina.
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to hcusto
Default

As you say, i did some reserchas about ASP.NET 2.0 controls , and I am now using Login Control and it's working great. I will now start a new topic becouse i need some help with accessing users profile values (for all users).

Thnx for this help Imar,
Haris

Reply With Quote
  #9 (permalink)  
Old November 29th, 2006, 02:25 PM
saf saf is offline
Authorized User
 
Join Date: Nov 2006
Location: , , .
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi again Imar -

I've been searching for days to see if this is possible and don't think it is but thought I'd check with you first -

I want to use the Login Control and provider models but I also want to provide a dropdown list of usernames for login.  Let me explain my situation so you know what I'm talking about.

I am creating an orders database.  In order to gain initial access to the system, each person will login using their name and a password that will be provided to them when their administrator signs on with my website.  
So the initial security is loose, as long as the administrator gives out the password user will get to their main order form.  Anyone who logs in this way will be assigned to a role and authenicated throughout the system based on that role, so that they can only access their own form.

So I will have many users logged in with the same username at one time which I don't think will be a problem.  Only users that will login with a username will be the administrators and this will be done once they get passed the inital login.  

I guess all I'm asking is whether there is any way to customize the login username text field to use a dropdown list.  I'm pretty sure I read somewhere that it has to be a textbox.

If not I'm sure there is an easy way to do this only I can't seem to get it to work.  Like I said, I would really like to use all the role/membership functionality already set up with asp.net to authenticate my users once they get to their main page.

Thanks!
Reply With Quote
  #10 (permalink)  
Old December 2nd, 2006, 08:14 AM
Imar's Avatar
Wrox Author
Points: 65,739, Level: 100
Points: 65,739, Level: 100 Points: 65,739, Level: 100 Points: 65,739, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 15,978
Thanks: 64
Thanked 1,350 Times in 1,330 Posts
Default

Hi saf,

If I understand you correctly, this can be done, and it isn't too hard. Here's what you should do:

1. Add a Login control to the page and convert it to a template (on its Task pane)

2. Hide the table cell that holds the UserName textbox using runat="server" and visible="false". The login control checks to see if there is a UserName so you can't remove it, but hiding does the trick.

3. Add a new table cell to replace the text box and add a drop down control.

4. Add an ObjectDataSource control with its TypeName set to System.Web.Security.Membership, its SelectMethod to GetAllUsers and its DataObjectTypeName set to MembershipUser.

5. Hook up the DropDownList to the ObjectDataSource control by setting the DataSourceID to the ID of the ODS and set both DataTextField and DataValueField to UserName.

6. When you now run the page, you get a nice drop down list with all the user names in the system, instead of the original user name textbox.

7. The final step is to fill the UserName property of the Login control with the selected value of the dropdown list. You can do this in the LoggingIn event of the Login control. You need to "find" the DropDownList and then cast it properly, retrieve its SelectedValue and assign it to the UserName of the Login.

This way, a user can select a name from the drop down. When they click the Login button, the selected user is passed to the authentication process.

You'll find the relevant bits of code below.

Hope this helps.....

[ODS control in the Login page]
Code:
<asp:ObjectDataSource ID="ObjectDataSource1" 
  DataObjectTypeName="MembershipUser" runat="server" 
  SelectMethod="GetAllUsers" 
  TypeName="System.Web.Security.Membership">
</asp:ObjectDataSource>
[Login control with DDL and hidden text box]
Code:
<tr>
  <td align="right">
    <asp:Label ID="UserNameLabel" runat="server" 
        AssociatedControlID="UserName">User Name:</asp:Label>
  </td>
  <td runat="server" visible="false">
    <asp:TextBox ID="UserName" runat="server"></asp:TextBox>
    <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" 
        ControlToValidate="UserName" ErrorMessage="User Name is 
             required." ToolTip="User Name is required."
        ValidationGroup="Login1">*
    </asp:RequiredFieldValidator>
  </td>
  <td>
    <asp:DropDownList ID="DropDownList1" runat="server" 
       DataSourceID="ObjectDataSource1" DataTextField="UserName"
       DataValueField="UserName"></asp:DropDownList>
  </td>
</tr>
[The LoggingIn event of the Login control]
Code:
Protected Sub Login1_LoggingIn(ByVal sender As Object, _
      ByVal e As System.Web.UI.WebControls.LoginCancelEventArgs) _
      Handles Login1.LoggingIn
  Login1.UserName = CType(Login1.FindControl("DropDownList1"), DropDownList).SelectedValue
End Sub
Please let me know if this works for you.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
Reply With Quote
Reply


Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
User Accounts ASPNET.mdf pschulz ASP.NET 2.0 Basics 3 June 19th, 2008 12:41 PM
Users with accounts PankajGarg10 General .NET 0 April 13th, 2007 01:06 AM
Blocking user accounts Ben Horne Forum and Wrox.com Feedback 10 April 29th, 2004 10:19 PM
Accounts RM82 BOOK: ASP.NET Website Programming Problem-Design-Solution 2 April 7th, 2004 09:37 PM
Enums for accounts??? rcarter BOOK: ASP.NET Website Programming Problem-Design-Solution 3 November 7th, 2003 11:07 PM



All times are GMT -4. The time now is 03:46 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.