I have an exisiting database which I used to create a Model usign the Database first approach. Please refer to the database diagram.
In my solution file, I have a Class Library of the model which has an ADO.NET connection to the database & and I a ASP.NET MVC 3 web application.
The funcitonality that I'm trying to get here is that - the information displayed once a user logs in is different for every user. How do I link the user login page to the 'user' table of the database? Is it directly using the connection string or do I need to go through the model that I created using the Database?
Add a field to your User table called "ProviderUserKey" or MembershipUserID, or something similar of type uniqueidentifier. You then call Membership.GetUser().ProviderUserKey and use that in your where clause of your User Table to select the correct User record based on the logged in user.
Related
I am using Oracle Apex v5.1 and application is using LDAP authentication.
I have a separate 'Create new user' form in application which is inserting user details such as NT-IDs, privilege into a user table.
Whenever user is logging to application, login password is been taken care by LDAP directory.
I want to know that is there any way to get user details such as full name, email address etc from LDAP directory instead of manual insertion into my user table?
What query I can use, so that User name/Email id will automatically inserted into table once user has created in that Oracle Apex form.
Please help. Thank you.
You can connect to LDAP using PL/SQL APIs, as described by Tim
You could then construct a pipelined function around this to allow you to query using SQL.
For performance, you could create a materialised view on this query.
This technique was also described in a chapter of an APEX book co-authored with John Scott.
I'm trying to create an admin controller and custom views that allows me to use CRUD actions for the Identity generated tables in my net core 2.0 project when I choose to use Individual User Accounts auth. I already have defined my roles "Admin", "Client" and "Employee" to my users, so far my project has a default admin, and whenever an user registers into my project, the default role created for him is the Client one.
What I want to know is if there's a way to generate an scaffold with a controller and views to administrate users using CRUD actions whenever I'm logged as the admin, I want to know if that's possible, because when I try to generate a new scaffold using the model Models/AccountViewModels/RegisterViewModel.cs it says that:
There was an error running the selected code generator
'The entity type 'RegisterViewModel' requires a primary key to be defined'
You cannot generate scaffolds using view models. Only entity types are supported. That said, just don't scaffold. It's training wheels for when you don't know how a controller should be structured. All you need is a class that inherits from Controller and has one or more public methods that return IActionResult.
I have an intranet application for which the URL is as follows
http:\\ServerName]\RunLog\
I am adding another department/tenant/group of users which will utilize the same instance of the application and same database. Their data will be different from the existing users. I am planning to add new column foreign key in each table to identify the specific tenant. I authenticate users windows authentication. I am thinking that the access to the application will be as follows
http:\[ServerName]\Platform1\RunLog
http:\[ServerName]\Platform2\RunLog
So for the above URL, how could I go about achieving that in the Application? I know how to make the table changes in SQL server, Updating the Entities, Updating the linq code in the controllers to pull up respective tennant data. Any help to get me started would be appriciated.
Kindly note that as you have given in your post, it is possible to identify the tenant's based on their URL. The table that contains the tenant details will also contain their url. So you will identify the tenant based on the URL. After identifying the tenant, we can authenticate the user's using the found tenant id / tenant code, get the tenant's configuration or settings using the same tenant id / tenant code.
I hope that you could have all the other entities of the application with a column called as TenantId. This will help you to fetch the data based on tenant. Your only change will be in the data access layer where you will filter the data that you retrieve from the Database.
Let me know if you have any other clarifications regarding the other specifics of this implementation.
I am looking to see what is the best way to implement asp.net membership in an MVC 3 project. One thing to note is that I have a separate users table and would like to still use this. So can I link my users table to the asp.net memberships table?
Cheers,
Noel.
You can create an additional field (unique identified type) on your custom table and link it to the membership users table.
create new user, if succeed then get id for the newly created user and insert it to your custom table.
MembershipUser mUser= Membership.GetUser(username);
Guid myId = (Guid)mUser.ProviderUserKey;
...Insert my/id to your custom table.
Description
You can implement your own MembershipProvider. Then you have full control about
how authentification works and wich database / tables are relevant.
I think you dont need the default asp.net membership database.
More Information
Create a Custom Membership Provider?
I am using the default membership authorization that is created when you start a new project in VS for MVC 3. When a user is registered (either if I do it for them in the Administration page or if they register themselves through the Register page created in the application), there is an email field for instance. But where is this stored? Shouldn't I be able to access that e-mail somehow? I can't find it in the User object...
Also, is it possible to add more fields when they register, and to access those as well? For instance address, phone number, etc?
1. Getting the e-mail
You can access the property from the current user by using the Membership object.
Membership.GetUser().Email
2. Extra Fields
The best way to add more fields to the register process is to make another model called UserDetail or something. And make a relationship between User and UserDetail.
Or you throw away the default membership authorization and make a custom one. Here are some handy links:
http://msdn.microsoft.com/en-us/library/f1kyba5e.aspx
http://www.asp.net/learn/videos/video-189.aspx
http://www.15seconds.com/issue/050216.htm
http://davidhayden.com/blog/dave/archive/2007/10/11/CreateCustomMembershipProviderASPNETWebsiteSecurity.aspx
For the extra user fields you can use the ASP.NET profile provider.
here is a good article about how to implement it:
http://ashuthinks.wordpress.com/2012/01/08/asp-net-mvc-profile-provider/