I am attempting to build an ASP.NET MVC website which allows certain domain users to login and access the various functions it offers. I'm building this using Azure AD which Azure has a really nice way of letting you download a pre-built application which comes withe a Windows login page and authenticates the user already.
Here is the login page. It is even pre-populated with my domain.
Username#mydomain.com
After a successful login however the User.Identity.Name property is null.
I did some searching online and found a ton of posts like this that recommended turning Anonymous Authentication off and Windows Authentication on in the project properties. I gave that a shot but it automatically signs me in, completely bypassing the login page, and the User.Identity.Name is the name of the PC I'm developing this on. Is there a way to have Windows Authentication enabled and still have the login page working?
EDIT 1:
I forgot to mention, the User.Identity.Name property is null after the user has been authenticated for login.
Related
I have an Asp.Net Core 2.1 web application which uses Azure AD to authenticate users. The application has recently had the 'user assignment required' option set within AAD so that only certain users are authenticated to use the application. This works correctly though I am now looking to make the user experience better for users that have an account in AzureAD but have not been assigned to the application. Issues I have:
For user that has not been assigned, the OnRemoteFailure event is hit. I can potentially parse the failure message and look for text like 'The signed in user is not assigned to a role for the application' and direct the user to an appropriate error page. Is this the best way to handle this? I cannot see any other data I can tap into to distinguish this type of response?
Some users will have two Azure AD accounts and it is possible that one is assigned to the application and another is not. In the case that they sign in to the Azure account that does not have access to the application, they will be stuck with each click of Login taking them straight back to the website and the Unauthenticated page. Ideally the user needs to be given the chance to login using their other AD Account rather than having to clear their browser cookies to reset things. I'm not sure how I would go about this?
For the second part, I have found that adding:
options.Prompt = "select_account";
to
services.Configure<OpenIdConnectOptions>(AzureADDefaults.OpenIdScheme, options =>
has done the trick and is allowing the user to switch account
I'm kinda new to .net development and in my company, they've been using forms authentication for a while. But as we wanted to use external login integration, I implemented from the Microsoft Documentation as given here.
Previously as my company was using Forms Authentication and my integration for external login being correct, I was redirected back to the login page after clicking for login with other providers.
So, I disabled authentication to None in my web.config and my external login with OWIN integration is working fine but now after Logging-in normally on my site it redirects me back to the login page and I'm not getting what's the issue or how can I get back both of them to work. I need a solution to get both forms and identity authentication to work or something that'll get my work done. I also got something to suppress default authentication but I'm unable to get it to work.
I have an ASP.NET MVC site currently working with forms authentication.
I want to add the ability for some users to use a special link I send them, this link will grant them direct access to the site without having to login. Problem is, that even the call to my contoller still goes through the login page.
Any ideas on how to make this direct login without giving up on the forms authentication for all other users?
I'm developing a MVC application that will require a user to be authenticated against an AD. how to create log in page in MVC to create an Intranet Application that automatically authenticates a user against an AD
Why don't you use the Intranet Template provided by Microsoft Visual Studio, which does exactly what you want out of the box?
Your requirement is paradox. Why do you want a login page, which does login a user automatically, while being logged in by visiting the (main-)site automatically, does not require the visitor to do anything at all, because he is already authenticated by entering his credentials at the windows-logon
More information: http://msdn.microsoft.com/en-us/library/gg703322(v=vs.98).aspx
you can use the built in windows authentication feature. the example is in here
if you need mixed authenticated for example you want the user can access from outside using their AD it will involve either two applications or two different pages for authentication types. find the example here
I'm not entirely sure if you actually want a login page that automatically authenticates a user that visits the main site. Maybe your wording is a bit confusing there.
I'll asumme you want your Web-App to be able to authenticate users against AD after having to log in with intranet credentials. If that's the case, you might want to have a look at this article detailing how to set that up using IIS and an ASP.NET app.
If not, please disregard this answer.
Ok... I have created a web application using Visual Studio 2008 using C#..
Now i need to secure this website; for that i need to add a login page.
I am not using the login control of visualstudio.. i am just entering the username and password and there is an API which returns true or false after authentication...
If it returns true the user is allowed to access my application and if false an error page is displayed... Is there a secure way to do this
Currently what is happening is that when i publish my web application and store it in the webroot directory of the server... the webpage can be opened simply by typing "http://ip address/Default.aspx" or "http://ip address/Page1.aspx". So i dont want this to happen instead if this is typed an error page should open. But if the user goes to the login page and logs in then only it should open these pages....
Any suggestions on how to achieve this..
thanks
use FORMS authentication in asp.net
Forms authentication uses an authentication ticket that is created when a user logs on to a site, and then it tracks the user throughout the site. The forms authentication ticket is usually contained inside a cookie. However, ASP.NET version 2.0 supports cookieless forms authentication, which results in the ticket being passed in a query string.
http://msdn.microsoft.com/en-us/library/aa480476.aspx
http://msdn.microsoft.com/en-us/library/xdt4thhy.aspx