I have application which stores all the user specific information in one database. But, I want to make user specific database. For instance, when user register in application then it should create database for that particular user with the same schema, which i currently have in database. Guide me if there is any solution for it.
Related
I have an MVC 5 application set up with windows authentication and my own custom roles table for authorization. This works fine if the user exists in my application database - username in my users table maps to the usernames in active directory.
My question is how do I keep my users table in sync with active directory. Any time a new user is hired, a new record has to be added to my intranet application to ensure this user has access to it.
Is there a way to load users from active directory into my own users table perhaps with some kind of scheduled job or is there a better way to achieve what I'm trying to do?
I think sync two database instances (AD database and you app database) will become management issue as your business grow. Even, adding new user and removing is day to day work, so in both cases you need to execute some sort of action to add or remove users from your app database.
Why don't you ask your team to give you access of AD database and consume this into your intranet app, this is what I was using in my past organization and this works great.
The AD can be used in a programmatic manner. Just look for LDAP stuff and you'll find lots of examples. Here's one to get you started : Connect to Active Directory via LDAP
If your application allows people to register then implement your own custom membership provider which talks to the AD. You can create the users in the AD, you will have to pass the password requirements which are set on the AD as well, which is more than likely a good thing. The roles information can be stored there as well, no need for a local custom roles table either.
I want to create a multi-domain app with Rails and have been wondering about the best approach.
The app will have a set of functionality that will be the same functionality across all domains, so the change in domain will only mean a change in the db used and the styling (and content obviously) but the models and controller will be the same.
The app will use MongoDB as the main storage (Redis for workers and other stuff that not directly relevant to model storage)
My idea is: Once a user signs up, a new record will be created but also a database will be created with the user id. The user model will store the database id (recently created), and the domain the user have just added. A vhost file would be created and the server reloaded.
Once the user visits the app (using the new domain). the app would check the url and find the correct db to use based on url. This would be saved into variable to be used throughout the app.
I imagine have this check to happen on each request.
I would appreciate thoughts and comments on this approach and best way to achieve this.
I have been learning how to use ASP.NET MVC4 and have been getting my head around authenticating users and user roles and posting data using the entity framework to SQL.
However I have not been able to find any guides/resources (maybe I don't know the correct term) for posting and retrieving data that is unique to an specific user. For example how would a user only see the entries that they created if it was a site that stored data that is personal to each user.
What patterns/designs does one use when trying to do this?
Creating a sandbox of data for a specific is usually tied to authentication. You can access this many ways through ASP.Net.
First of all, every user gets identified even if they never log in. They get a session identifier. It essentially creates a small place in memory for this user where you can store any user related information. Think of Sessions as walled gardens for each user.
Session["UserFullname"]
This works, but realize Session is limited by time, so it is very volatile. Utilize it, but don't depend on it.
The next method is to authenticate a User. This is done using Cookies, but usually handled transparently for you by ASP.Net Membership or other authentication providers. To access the authenticated User you just need to use a simple line in your Controller actions.
// User is the property
User.Identity.Name
Both these methods can store information about your user that you would use to query data specific to them.
Select * From Orders Where UserId = *User.Identity.Name*
Note that both Session and User are accessible through HttpContext.Current as well, as long as you are in a web environment.
HttpContext.Current.User
HttpContext.Current.Session
You won't need to access them this way unless you are not inside your Controller, or inside of another class that doesn't already give you access to the HttpContext. I don't recommend this way either, since your code could be used outside of a web application where HttpContext is not available.
I hope that makes sense, and please feel free to ask me questions.
This is not so much about mvc, but more about the problem of relating data to a specific user. You have to ask yourself, how would you identify a piece of data to a user.
The way you would do this is to tie the data to the user in the data store somehow.
In a relational database you would do this by having a User table and using the unique key on that table to insert data into another table such as Order. Order would then have a User Id.
When a user logs in, you could store that ID in session and use that to filter out orders based on the id.
We have an old PHP app in MySQL that we're currently rewriting in Rails and PostgreSQL.
I'm looking for a way to migrate users one-by-one when they first sign in to the new system, so that we migrate only active users.
Is there a hook in Devise that I can use to catch a failed login towards the new database and check if the user exists in the old MySQL database and migrate the user if found.
BTW, the Rails app can access both databases and the migration code is already in place that accepts old username as input.
Or should I just simply make a separate _migration_assistant_ page that accepts old logins and initiates the migration?
PS. any user can possibly have thousands of database records to migrate so it can take a bit of time, but we already make use of PosgreSQL's COPY FROM to speed it up (about a few secs per account).
EDIT:
There are currently about 5000 users and we expect roughly 1000 of them to return to the new site.
You could migrate the required data from just your users table. Include the original primary key in a column 'old_id'.
Create a custom encryptor so that users can log in with their existing password.
Redirect users when they log in to a page that triggers the migration process per user making use of the saved 'old_id'.
After your migration period you could look at the Devise trackable columns to determine which users can be cleaned up.
Hey everyone... I'm trying to access user information that's contained within the ASPNETDB.MDF file. I'm using ASP.NET MVC. This file gets created when you launch the ASP.NET Configuration tool from Visual Studio. So, I create users, roles, etc. via this ASP.NET Configuration tool, and the data gets saved to this database file.
I'm needing to gain access to user information (just the user name) to use within my application. For example, what I'm trying to do is populate a drop down list with a list of user names (which were created from the ASP.NET Configuration tool, and therefore reside within this ASPNETDB database file). I think if I can figure out how to get that information then I can figure out the rest.
Is there any other way someone would suggest me going about this? I could create a separate users table in my main database, but I would rather use the one in the ASPNETDB database that's already created, just so I use one source for my user's information and not two.
You can use Membership.GetUser() method to get all users in the database as a MembershipUser.
You can also use following LINQ Query to get a list of user names
var users = from user in Membership.GetUsers()
orderby user.UserName
select user.UserName