asp.net-authentication

How to get all users in a specific role?

☆樱花仙子☆ 提交于 2019-12-05 06:24:51
How do i get all users from a specific role? var users = Membership.GetAllUsers(); gets all users in all roles. it returns a list of MembershipUser , but there is no role property. Thanks You need to use the Roles class defined in System.Web.Security. It has a Roles.GetUsersInRole method. Here is the documentation. If you want to map the returned username to a MembershipUser you can use Membership.GetUser(string username) method on each of the returned values. Richard Roles are handled by the role provider not the membership provider (for separation of authorisation from authentication). So

How to use forms authentication without login control?

好久不见. 提交于 2019-12-04 17:43:00
How to use forms authentication without login control.I don't want to use asp.net login control in my site.But i have to implement forms authentication and to validate users in my database. I am assuming that instead of using a login control, you are using a few textboxes(eg username/password) and a logon button. The code could look something like this: In your aspx file <asp:Textbox runat="server" ID="Username"/> <asp:Textbox runat="server" ID="Password"/> <asp:Button runat="server" ID="Login" OnClick="Login_OnClick"/> <asp:Label runat="server" ID="Msg" > And on server side: public void Login

MVC 5 Identity Automatic Logout

岁酱吖の 提交于 2019-12-03 04:14:34
问题 How do I implement an Automatic Logout Timer. So basically if the user is inactive for x minutes their session is ended? I have tried: <system.web> <sessionState timeout="1"/> </system.web> But it doesn't seem to work. Here is code that is in my startup: public void ConfigureAuth(IAppBuilder app) { // Enable the application to use a cookie to store information for the signed in user app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes

MVC 5 Identity Automatic Logout

自闭症网瘾萝莉.ら 提交于 2019-12-02 17:32:11
How do I implement an Automatic Logout Timer. So basically if the user is inactive for x minutes their session is ended? I have tried: <system.web> <sessionState timeout="1"/> </system.web> But it doesn't seem to work. Here is code that is in my startup: public void ConfigureAuth(IAppBuilder app) { // Enable the application to use a cookie to store information for the signed in user app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, LoginPath = new PathString("/Account/Login") }); } Which says that I am using cookie

IdentityServer4 logout

ぐ巨炮叔叔 提交于 2019-12-02 05:36:13
问题 I am having an issue where I cannot seem to get my Identity Server logout to show the confirmation first. I downloaded the source code for IdentityServer4 from github and found the parameter in the Models folder: LogoutRequest.cs, ShowSignOutPrompt. There are no references to it in IdentityServer except to check it during the logout. In debugging, I see that it is false. I don't know where this is supposed to get set, I've checked the options for the client config on both the server and

Setting Up LinkedIn/OAuth Authentication in ASP.NET Core 2.0

匆匆过客 提交于 2019-11-30 15:24:00
I'm trying to add LinkedIn authentication to my ASP.NET Core 2.0 app but getting the following error: No authentication handler is configured to handle the scheme: LinkedIn Here's how I add LinkedIn/OAuth authentication in the ConfigureServices in Startup.cs : services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie("internal_cookie", options => { options.AccessDeniedPath = "/Account/Forbidden/"; options.LoginPath = "/Account/Login"; }) .AddCookie("external_cookie") .AddOAuth("LinkedIn", options => { options.SignInScheme = "external_cookie"; options.ClientId =

How to best handle permissions (not roles) in asp.net membership, specifically in ASP.NET MVC

和自甴很熟 提交于 2019-11-30 11:53:04
问题 There are plenty of questions (and information) on setting up asp.net membership, role providers and the like. Whether or not you should use the built in platform provided by microsoft, or role extend the base classes and role your own. I have decided to extend the default providers and implement my own membership and role providers. Now my question, is specifically around role authentication. Traditionally, you would create roles maybe like 'Manager, Administrator, Employee, Super User' or

What is the point of configuring DefaultScheme and DefaultChallegeScheme on ASP.NET?

≯℡__Kan透↙ 提交于 2019-11-30 08:31:38
问题 I am learning how security works on ASP.NET Core 2.0 and IdentityServer4. I set up the projects with IdentityServer, Api and ASP.NET MVC Client App. ConfigureService method on Client App as in below. Here I am confusing on DefaultScheme and DefaultChallegeScheme . What is the point of configuring those? A detailed description on how it works would be really helpful if possible. I already seen instead of DefaultScheme , DefaultSignScheme also works, but how does it work? What is the difference

ASP.NET Identity “Role-based” Claims

江枫思渺然 提交于 2019-11-30 06:27:16
I understand that I can use claims to make statements about a user: var claims = new List<Claim>(); claims.Add(new Claim(ClaimTypes.Name, "Peter")); claims.Add(new Claim(ClaimTypes.Email, "peter@domain.com")); But how should I store "role-based" claims? For example: The user is a super administrator. claims.Add(new Claim("IsSuperAdmin, "true")); The value parameter "true" feels completely redundant. How else can this statement be expressed using claims? This is already done for you by the framework. When user is logged in, all user roles are added as claims with claims type being ClaimTypes

How to best handle permissions (not roles) in asp.net membership, specifically in ASP.NET MVC

老子叫甜甜 提交于 2019-11-30 00:41:14
There are plenty of questions (and information) on setting up asp.net membership, role providers and the like. Whether or not you should use the built in platform provided by microsoft, or role extend the base classes and role your own. I have decided to extend the default providers and implement my own membership and role providers. Now my question, is specifically around role authentication. Traditionally, you would create roles maybe like 'Manager, Administrator, Employee, Super User' or whatever you have. But what would/should you do with respect to permissions which I consider to be a