asp.net-identity

asp.net azure active directory user profile data

谁都会走 提交于 2019-12-06 07:36:28
I'm working on a MVC application using Azure's AD authentication. I have been looking for a best practice or suggested way to 'extend' the user profile data. For example, I want the users to have a date of birth stored against themselves. I have looked at this but it doesn't really answer my question: Active Directory User Data Storage I can't find anything else kinda close to the solution either, all other solutions are for the other type of authentication. One thing to note is the application only has read access to the AD, if that matters for what im asking. I hope to just create a User

ASP.NET Identity - protecting a directory from unauthenticated users

筅森魡賤 提交于 2019-12-06 07:26:25
I am using ASP.NET 4.5 OWIN Identity and attempting to block access to a directory for all but authenticated users. The directory contains raw files, so it isnt possible to wrap them in the ASP LoggedInTemplate tag. When I try and prevent access to the directory to anonymous users, it fails. I have tried adding the following to the main Web.config file: <system.web> <authorization> <deny users="?" /> </authorization> </system.web> <location path="/docs"> <system.web> <authorization> <deny users="?" /> </authorization> </system.web> </location> Doing this gives server 500 errors and highlight

How to overload UserManager.AddToRoleAsync(string userId, string role)

蓝咒 提交于 2019-12-06 07:17:04
问题 I'm using Asp.net Identity Framework 2.1. I implement customized ApplicatoinUser, ApplicationRole, ApplicationUserRole, because I want to add support to multi-tenant, that is each user belongs to different companies, but I have 3 roles among all these companies, they are User, Admin and Approver. My ApplicationUserRole derived from IdentityUserRole, and have one more property: CompanyId. This property will indicate the user's role in this particular company. My code for these customized

Using a Web API Service as Central Authentication Point

南笙酒味 提交于 2019-12-06 06:59:47
问题 I'm very new to the identity management world, so please spare me. :) What I would like to do, is to have multiple client (MVC) applications that talk to a single Web API application to authenticate their users against. In that Web API application, I would like to use ASP.NET Identity to talk to a database with users. That way, I could use SSO for the client applications (I guess). Does that make sense? Could someone help me on my way to implement this (links are also welcome of course)? I

Asp.Net Identity 2.0 Custom Storage Provider using Dapper

谁都会走 提交于 2019-12-06 06:09:01
问题 I know this description is a bit lengthy, but its easy to follow. I have created a custom storage provider which uses Dapper as a replacement for Entity Framework. To do so I've created a class library called AspNet.Identity.Dapper. The Web app simply adds a reference to this class library to replace EF. Inside the class library is this code: In creating the custom provider I implemented my own UserStore. The UserStore implements all the interfaces. Here is the definition: public class

UserManager dependency injection with Owin and Simple Injector

↘锁芯ラ 提交于 2019-12-06 05:42:12
After adding Simple Injector to my project to create an instance of my UserAppManager that will exist through the whole lifetime of a session I started to recieve errors: Error with no parameterless constructor: An error occurred when trying to create a controller of type 'AuthController'. Make sure that the controller has a parameterless public constructor. Error with a parameterless constructor: For the container to be able to create AuthController it should have only one public constructor: it has 2. I followed a guide ( https://simpleinjector.codeplex.com/discussions/564822 ) to avoid

ASP.NET Identity 2 - injecting ISecureDataFormat<>

ぃ、小莉子 提交于 2019-12-06 05:10:26
I'm having same issue described here with no answer, just using Unity. I'm trying to register ISecureDataFormat<> in the lastest VS2013 (update 2) SPA/Web Api template. I've tried container.RegisterType(typeof(ISecureDataFormat<>), typeof(SecureDataFormat<>)); container.RegisterType<ISecureDataFormat<AuthenticationTicket>, SecureDataFormat<AuthenticationTicket>>(); container.RegisterType<ISecureDataFormat<AuthenticationTicket>, TicketDataFormat>(); It "works" but not really because then it complains about the next depenedency in that tree, IDataSerializer... and then the next IDataProtector,

Special language characters in username of ASP.NET Identity

Deadly 提交于 2019-12-06 04:33:28
I would like to use some special characters like ø in user name. But I am facing this error in IdentityResult result = UserManager.Create(applicationUser, password); Error: User name testø is invalid, can only contain letters or digits. How we can fix it? How to allow some special characters? I found what do I have to do public class ApplicationUserManager : UserManager<ApplicationUser> { public ApplicationUserManager() : base(new UserStore<ApplicationUser>(new ApplicationDbContext())) { PasswordValidator = new MinimumLengthValidator(4); UserValidator = new UserValidator<ApplicationUser>(this)

Merge MyDbContext to Asp.net IdentityDbContext

喜夏-厌秋 提交于 2019-12-06 04:25:06
I saw a lot of examples online but none that I could use from top to bottom about merging my own DbContext with Asp.net IdentityDbContext. Can someone please walk me through it? I am at step 0, and what I want is to have the tables generated by ASP.net IdentityDbContext inside my own database, so that I can retain user data in my own database. How can I achieve that? Thanx in advance :) If I got you correct, you are trying to use your existing database, tables and existing users with asp.net identity framework. First thing, according to my understanding, you can't merge your db context

UserManager.AddToRole not working - Foreign Key error

爱⌒轻易说出口 提交于 2019-12-06 04:15:52
In my ASP.NET MVC application I have some code which should be fairly trivial: UserManager.AddToRole(user.id, "Admin"); I just get this error... The INSERT statement conflicted with the FOREIGN KEY constraint "FK_dbo.AspNetUserRoles_dbo.AspNetRoles_RoleId". The conflict occurred in database "TestDatabase", table "dbo.AspNetRoles", column 'Id'. My ASP.NET Identity Framework is custom in that everything uses Guid as keys instead of int or string . Any ideas what is causing this? Edits, as per user comments... User class public class User : IdentityUser<Guid, UserLogin, UserRole, UserClaim> {