49 lines · 1.4 KB · C#
RawDownload
using System;
using System.Security.Principal;
using GSF.Collections;
using GSF.Identity;

namespace UserInfoTest
{
    class Program
    {
        static void Main(string[] args)
        {
            string userName, password, errorMessage;

            Console.Write("Enter user name: ");
            userName = Console.ReadLine();

            Console.Write("Enter password: ");
            password = Console.ReadLine();

            IPrincipal principal = UserInfo.AuthenticateUser("", userName, password, out errorMessage);

            if ((object)principal == null)
            {
                if (string.IsNullOrEmpty(errorMessage))
                    Console.WriteLine("Authentication failed with error message.");
                else
                    Console.WriteLine("Authentication failed: " + errorMessage);
            }
            else
            {
                Console.WriteLine("Authentication succeeded!");
            }

            UserInfo info = UserInfo.CurrentUserInfo;

            Console.WriteLine("Current user: " + info.LoginID);

            Console.WriteLine("Attempting initialization...");

            info.Initialize();

            Console.WriteLine("Groups: " + info.Groups.ToDelimitedString());

            Console.WriteLine("Next password change date: " + info.NextPasswordChangeDate);

            Console.ReadLine();
        }
    }
}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t