Solved

Hows can I create a new Application in the ASP.NET Membership?

Posted on 2008-06-19
8
270 Views
Last Modified: 2013-11-07
I'm using the ASP.NET Membership for my web site authorization.  I don't see an obvious way to create new Applications outside the Website Administration Tool.  Are there methods built in for this or do I need to just add them programmatically myself?
0
Comment
Question by:edenmachine
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 16

Expert Comment

by:GreymanMSC
ID: 21828675
You use the System.Web.Security.Membership and System.Web.Security.Roles objects to programatically create, edit, and delete members and roles.
0
 
LVL 1

Author Comment

by:edenmachine
ID: 21830909
Yes, I have no problem creating users and roles.  My question was how to create/add/insert a new Application.  There's a table in the Membership db that is called "Application" and each user belongs to an Application via an ApplicationID.
0
 
LVL 1

Author Comment

by:edenmachine
ID: 21830917
sorry the table is actually called "aspnet_Applications"
0
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 
LVL 37

Expert Comment

by:samtran0331
ID: 21832843
It sounds like you want 2 different asp.net apps to use the same membership database right?
You can't set the application id manually....but to make 2 apps use the same membership db.... in the web.config of both, just make sure they both point to the same membership database (same connection string) and if you want them to share users or not share users, follow the tip.

"Another important property to set in the membership configuration is the applicationName property. The applicationName allows one database to support multiple web applications. If you have two web applications and want both apps to share the same user base, give both applications the same applicationName and point them to the same aspnetdb database. If you want both applications to use the same database but not share users, give each application a unique applicationName property. "
http://www.odetocode.com/Articles/427.aspx

0
 
LVL 1

Author Comment

by:edenmachine
ID: 21835847
Actually it's really just one Web application but I would like to separate the Users by Company so there could be duplicate usernames for each Company.

Like Company A could have a jsmith and a Company B could also have a jsmith but there can't be two jsmith usernames in Company B or Company A.  The only way to do this is to have an application for each Company I would think.  I guess I could just insert the Application records manually - just figured there was a built in method to do that.  I would have figured that I wasn't the only person on the planet that needed to do something similar to this.  Am I way off base in my thinking here or something?  I there a better way to do what I'm trying to do?
0
 
LVL 37

Accepted Solution

by:
samtran0331 earned 500 total points
ID: 21845156
Out of the box, there isn't a method to do that (that I know of).
I guess MS didn't have that functionality in mind with their base membership.
But they did do a great job of making the membership fully customizable and extendable.
So it would be possible for you to do something like add another primary key to the user table and then on the login, require the user to enter their company name...
or if you force the user name to be an email address, then jsmith@companyA.com and jsmith2companyB.com would be fine using the out of the box membership.
0
 
LVL 1

Author Comment

by:edenmachine
ID: 21846172
Yeah, after messing with it - Application doesn't allow for what I'm trying to do.  I did add on company name at the login and I had to append company name to the username so that it'll allow for non-unique usernames accross different companies like: Acme_JohnSmith and WiggetCo_JohnSmith since I can't just have two JohnSmith usernames otherwise for different companies.  I just had to tap into the Login functionality and append the company and username when they log in.

However,  I kind of like the email address for a username idea a lot better - I never thought about doing that.  That would kind of solve all my problems and keep me from having to ask them for company each time they log in.  Plus, using email address for login is pretty acceptable these days anyway.
0
 
LVL 37

Expert Comment

by:samtran0331
ID: 21846311
>>keep me from having to ask them for company each time they log in

You could still do what you're doing, but you don't have to "ask" the user to input/choose the company name by using a querystring variable...
Like tell everyone at company A to login to the site at:
http://www.yourapp.com/login.aspx?Company=Acme
and then you can use the querystring value to append...

At least that would make it a little easier on the user...

or even a bit better, have a company table in the db so that you can:
http://www.yourapp.com/login.aspx?CompanyID=2 
etc..
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question