Delphi Single Sign-on module

Overview

Want to add Single Sign-on to your Delphi application with just a few lines of code? Then this module is for you!

You can use this module via a simple interface, which retrieves the information of the logged-in user. Using this information you can check whether a user is allowed to use the application. The interface can also be used to allow users to link their Windows user to their own account in the software.

How to use

You can retrieve information through the following interfaces. The Windows User Info (IWindowsUserInfo) interface contains the details of the logged-in Windows user. The Fully Qualified Domain User Name is the user name including the domain. Use this function to authenticate the user.

  IWindowsUserInfo = interface
    function Username: string; 
    function Domain: string; 
    function FullQualifiedUserName: string; 
    function UserFound: Boolean; 
  end; 

  ISingleSignOn = interface 
    procedure CheckUser(const Action: TProc<IWindowsUserInfo>); 
  end; 

The module contains a sample project showing how these functions can be used. Below is a simple code example to retrieve the logged-in Windows user and show the username in a form.

begin 
  // Use the simple access to the check user function, 
  // using the TSimpleSingleSignOn class procedure 

  TSimpleSingleSignOn.CheckUser( 
    procedure(UserInfo: IWindowsUserInfo) 
    begin 
      // At this place you can add your own authentication or display code 
      // Or you can use the info to link it with the application's user info 
      DisplayUserInfo(UserInfo);  

      if not(UserInfo.UserFound) then 
        MessageDlg('No user found.', mtError, [mbOk], 0) 

    end); 
end; 

In a similar way, it is also easy to look up the user while logging into the application.

var 
  SingleSignOn: ISingleSignOn; 
begin 
  SingleSignOn := TSingleSignOn.Create;  

  SingleSignOn.CheckUser( 
    procedure(UserInfo: IWindowsUserInfo) 
    begin 
      // At this place you can add your own authentication or display code 
      if UserInfo.UserFound then  

        // Check if the username and domain corresponds with the input fields 
        // Most common is to store the Fully Qualifield User Name for each user in your application 
        // In that case you can find your user using SQL (for example): 
        //   "SELECT * FROM User WHERE FullyQualifiedName = :UserInfoFQN"  

        if (UserInfo.Username = edUsername.Text) and 
           (UserInfo.Domain = edDomain.Text) then 
          MessageDlg('This is the current system user!', mtInformation, [mbOk], 0) 
        else 
          MessageDlg('Current system user is not the given user.', mtInformation, [mbOk], 0) 
      else 
        MessageDlg('No user found.', mtError, [mbOk], 0) 
    end); 
  • Easy to use interface
  • Including source code
  • Fully Qualified Domain User Name
  • Examples provided
  • No installation required

Supported platforms

  • Delphi XE2 to Delphi 12
  • Windows 32-Bit / Windows 64-Bit

Get your copy now!

  • Including source
  • Unlimited users / site licence