Demystified Series: WinForms App Single Sign On in 2 Lines of Code!

Play Demystified Series: WinForms App Single Sign On in 2 Lines of Code!
Sign in to queue


Welcome to the Demystified Series where we seek to identify and present the strategic and critical pieces of information that a developer needs to get up and running, and feel confident, in building identity-aware, directory-enabled applications.

Many developers are unaware of two information rich objects available to them for role-based validation and that can also be leveraged to verify authenticated access, essentially single sign on (SSO), to their application because the user has already logged onto the desktop. These are the WindowPrincipal and WindowsIdentity objects. The purpose of this screencast is to demystify how to leverage the rich information these objects provide – starting with just 2 lines of code.

For further information regarding Identity and Access Management, please visit:



The Discussion

  • User profile image
    Very cool:P

    What are you using behind the scenes? Is this basic AD? I am wondering how I would set this up.
  • User profile image


    In Microsoft Visual Basic 2005 Express Edition, the line of code below


    gives me the following error

    Value of type 'System.Security.Principal.PrincipalPolicy' cannot be converted to 'System.Security.Policy.PolicyLevel'.

  • User profile image

    Thanks! The great thing about using the WindowsPrincipal and WindowsIdentity objects is that there is no set up required – yet these encapsulate information about Windows accounts whether the machine is domain attached or not. Therefore, simply pull in the appropriate namespace(s) and instantiate the objects required for either your single or repeated validation use. From there, if desired, the developer can interrogate the Name property to evaluate for a specific DOMAIN\ requirement for access to the application. The application could then be terminated with an error prompt based on the evaluation or possibly pop up another form to collect credentials for authentication to another identity store. Also, the Type property shows the type of authentication used to identify the user – Kerberos, NTLM, etc. There may be business reasons for the application to also make decisions based on this information.

    It appears that you need to adjust your syntax just a bit to:

    This should fix it. Smiley

  • User profile image

    Hi, I could not run the video on IE 10 or Chrome! I have installed Silverlight on IE 10.

Add Your 2 Cents