I have a stand alone Windows app. I want to bring Windows Authentication into the app for logging purposes. I can't find anything on the web about how to do that. Or something similar. The app was written in C# VS2012.
If you only need to log the information, then getting the current user running the app should be enough. To get the current user you can use the WindowsIdentity.GetCurrent() method, which returns a WindowsIdentity that has a Name property:
Console.WriteLine(System.Security.Principal.WindowsIdentity.GetCurrent().Name);
Related
I am working on a desktop application that needs to configure user authentication and authorization with the AD. I am developing this application as Windows Form Application.
I faced following issues and I am looking for the right direction.
In my research, I saw that there is no session state like in web application. So once I configure the AD with desktop, How to manage the user token that provides by AD?
Once the user closes the application without log out, when the next time that user should be able to open the application without login. So what is the approach to achieve that?
I am working on a desktop application that gives a desktop tray icon notification when a new pull request is created that requires your attention.
I have developed the application entirely using a public access token for my account. Now I have got to the point where other users need to be able to use the application, I am required to implement OAuth 2.0 authentication.
However, VSO's application authentication assumes my application is a web app and asks me for details that I cannot provide (and aren't even relevant).
How can I get an app id so other users can use my application?
I'm not sure if I'm misunderstanding the whole concept. This is the link I am using: https://www.visualstudio.com/en-us/docs/integrate/get-started/auth/oauth
There is no way to do this for now:
Right now, Visual Studio Team Services only support the web server
flow, so there's no supported way to implement OAuth for Visual Studio
Team Services from an app like a phone app, since there's no way to
securely store the app secret.
As an alternative way, you can use Basic Authentication and ask your users enable "Alternate authentication credentials" and then use the alternative credential to authenticate to VSTS API.
I have done some work in Asp.NET, and i am quite used with user authentication using FormAuthentication
Now I am working on a desktop application and i want to have something like above in windows form application, I want to create and authenticate users by using the application database or xml whatever it is like i have done it in Asp.NET. So far did not any way to achieve this like i want to.
Any help would be great!
A Windows desktop application is nothing like an ASP.NET web application.
You cannot call the different forms separately.
(well you can hack the application, but if you do that, you can just as well remove any password protection)
Hence forms authentication does not make any sense.
You can create a login window as startup window, and check username and password against the database.
And that's about it.
It's a Windows application, you don't need membership provider, forms cookie ticket, etc. because unlike HTTP, Windows desktop applications are not stateless.
PS: If you do a WinForms application, make the login via ActiveDirectory authentication.
There is no point in using FormsAuthentication with Windows applications. What you can do is to use Membership, MembershipUser and Roles classes. All you need to do is to configure Membership and Roles providers in app.config.
FormsAuthentication does not actually authenticate your users. If you call Authenticate on FormsAuthentication you will see that it is obsolete method and that Membership.ValidateUser is used instead.
One drawback of these functionalities is that they are part of System.Web namespace which means that you have to use Web functionality inside of your Windows application. But if it can get the job done and fulfills the requirements, then go with it.
I am trying to add Windows authentication to an existing website that I have created. All information that I have read regarding using Windows authentication in silverlight requires that you start with the Silverlight Business Applicaion template instead of the Silverliight application template. I already have a website that I started writing using the Silverlight Application template. How can I add windows authentication to this existing website?
If your application is hosted in IIS and this is a intranet site, you just need to set the application in IIS authentication method to Windows Authentication, then when the client tries to load the SL App a 401 challenge will trigger asking the user to enter in his/hers credentials. You can also set IE to pass with windows credentials to the server when the site is loaded.
I have had spent quite a bit of time tweaking various properties to get the right functionality that i am looking for (especially with machine names being fully qualifies or not) but basically that's one thing to keep in mind when debugging this is that machines names play a role in how the server interprets a client trying to access the server.
I have a simple silverlight application hosted on a corporate network. However I want to allow access to this website to few select NT users and restrict the rest. How do I configure it?
Also would such a configuration work for out of browser as well?
you should enable the Integrated windows authentication in the IIS web site or virtual directory configuration. After that in any moment you can take the User.Identity and User.Principal objects and cast them to WindowsIdentity and WindowsPrincipal and check if current user is in a certain role ( aka in a windows group ) or his/her username...
about out of the box I don't know because I have never tried it but you could surely test it once you have a label showing current user name in your SL User Interface, checking if the functionality is the same in the browser or out of browser. Hope this helps...
There are several things you can do.
1) Restrict access to the web services this is calling into - Davide's answer covers this nicely.
2) Restrict access to thw website where the SL app exists, which is easy to do with ASP.NET and the built-in support for Windows Authentication via a MembershipProvider. This way, a user can't even load the HTML page hosting the Silverlight app if they're not in the right role. This would also prevent them from installing the app as Out of Browser, as they can never get to it in the first place.
3) In the OOB mode of the app (when Application.Current.IsRunningOutOfBrowser is true), at startup call into a web service that verifies the user is in the right role - if they're not, the app could simply diplay a "not authorized" visual and not show the real app functionality.
This way, if the user ever was in the role and installed the app OOB, but then lost that permission, they'd still not be able to use the app.
As to implementation of all this, I suggest looking at WCF RIA Services. It has great authentication/authorization support that should simplify implementing this, even if you don't want to use RIA Services for data access for whatever reason (though I recommend that as well, it helps hide a lot of the async complexity of Silverlight data access).