I am having this strange problem with Windows Authentication in ASP.NET.
A user complaints that he cannot use his username to access one of my systems. However, the username is correct and every other user is able to access it.
When I tried to use my C# code to query the Active Directory to look for that user, I get an error that the user is not there! But, he is.
when I sent this to our technical team, they said that it is because the username is "too long" and then they gave me another one. which worked.
how can a user have an active username on AD and still cannot use it to login to ASP.NET web app
any idea?
Related
I have a website deployed on a server with it's own domain. Is it possible to get the Windows username when that website is launched?
Say i have a website on foobar.com, when i access the site from any random windows desktop, i want to retrieve the windows username from client side.
I use this in code to access the username:
HttpContext.Current.Request.LogonUserIdentity.Name;
But this brings up a login prompt for the server that the website is residing, which doesn't help me. Even if i did log on to that server, it is still not getting the current user's windows username.
I have searched almost every post relating to this, but none are specific in this scenario.
IIS is setup to only windows auth. Any info on this is appreciated.
I have finally come to the conclusion that this is not possible. Instead went with integrating with Azure AD.
a c# windows application give privilege to users with a specific profile in its database. The application does not handle user and password but get the username of the authetcated user in Windows session.
They asked me to authenticate the user by a IAM service such as Microsoft IAM. But I'm a bit confused. It means that I have to ask username and password to user and verify them with IAM? I don't want to store in my db password.
I cannot figure how to use an external IAM.
No, you will not need to deal with passwords.
In short, your application will need to display a mini browser window (WebControl, WebView, etc.) where the IAM provider's login screen is displayed. Users provide their credentials directly to that login screen. Your application never touches those credentials and only receives the valid tokens afterwards from which it can get information like unique user ID, email address, etc.
Check out this WPF tutorial from one of the best IAM providers, auth0 (disclaimer: I'm not affiliated with auth0 in any way).
https://auth0.com/docs/quickstart/native/wpf-winforms/01-login
You can sign up for a free trial account to quickly try it out.
Side note: This method is not entirely safe from abuse as your malicious application could intercept key strokes as users type in their credentials into the IAM login page (since it is hosted within your application's process).
I am building a web application for my school's intranet. Whenever teachers try to access the browser to access the intranet page a popup appears so they can login, in my page I need to get the logged username. do any of you guys know how to do that?
System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();
The code above is what I've managed to do so far which gets the username of the user loggin in on windows but that's not really what I want.
you can use simply the following statement :
HttpContext.Current.User.Identity.Name
this is my scenario: I'm developing a web application where the user logs in, when he clicks a link I want him to be redirected to a Sharepoint site and I want to automatically pass to Sharepoint his username and password, therefore he doesn't need to log in.
How should I do this? Please indicate me the best strategy. I have already tried with this, but it did'nt work out.
http://forums.asp.net/t/883397.aspx
The login via NetworkCredential seems to work fine, but when I redirect my page to Sharepoint it prompts me again for user and password.
Thanks in advance.
We did something like this on a application I was working on (although it wasn't a SP site). You want to setup the web.config so that both site can decode the authentication token (cookie) that is set in your web application. Take a look at this article on MSDN that describes how to configure forms authentication across applications.
I wonder if the following is possible.
A user logs in on my website, using a username and password using his default browser.
Later on, my C# program is run on the same PC. I want to check if the user is logged in in the default browser, so I can access a webpage that is in the registered-only area. Is this somehow possible?
I number of possibilities come to mind:
You could check their cookie folder for a valid cookie for your site
Check the browser history (perhaps using a toolbar)
Use the web browser control so that users log-in through your app
I have never seen either of the above in practice.
I think the best method would be to set up the site to ask for credentials if they're not logged in - so the user can enter them and continue. You'll find this method in most (if not all) of the major websites out there that have client installed software (such as the Gmail Notifier)
You could possibly do it with a cookie saved on the machine, you would need to find where its stored and the naming of the cookie or some kind of api to read the cookie.
here is a few links
http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.cookiecontainer.aspx
http://msdn.microsoft.com/en-us/library/system.windows.application.getcookie.aspx
http://bytes.com/topic/c-sharp/answers/677862-reading-creating-cookies-local-machine-using-windows-application
http://www.codeproject.com/Messages/2981086/How-to-read-cookies-in-winforms-Net.aspx