Click or drag to resize

UserInfoAuthenticateUser(String, String, String) Method

Authenticates the specified user credentials.

Namespace: GSF.Identity
Assembly: GSF.Core (in GSF.Core.dll) Version: 2.4.253-beta+ffb7163c9e3b771705bc5b9aa3f09870f2cb9e2c
Syntax
public static IPrincipal AuthenticateUser(
	string domain,
	string userName,
	string password
)
View Source

Parameters

domain  String
Domain of user to authenticate.
userName  String
Username of user to authenticate.
password  String
Password of user to authenticate.

Return Value

IPrincipal
true if the user credentials are authenticated successfully; otherwise false.
Example
This example shows how to validate a user's credentials:
C#
using System;
using GSF.Identity;

class Program
{
    static void Main(string[] args)
    {
        string domain = "XYZCorp";
        string username = "johndoe";
        string password = "password";

        // Authenticate user credentials.
        if (UserInfo.AuthenticateUser(domain, username, password) is not null)
            Console.WriteLine("Successfully authenticated user \"{0}\\{1}\".", domain, username);
        else
            Console.WriteLine("Failed to authenticate user \"{0}\\{1}\".", domain, username);

        Console.ReadLine();
    }
}
See Also