| 
            
              UserInfoAuthenticateUser(String, String, String, String) Method
             | 
          
        
        
             Authenticates the specified user credentials.
             
        
        Namespace: GSF.IdentityAssembly: GSF.Core (in GSF.Core.dll) Version: 2.4.258-beta+f8b6aa3dbfe0b4cc2b0b0760dd5d2a3dd4f59d09
Syntaxpublic static IPrincipal AuthenticateUser(
	string domain,
	string userName,
	string password,
	out string errorMessage
)
Public Shared Function AuthenticateUser ( 
	domain As String,
	userName As String,
	password As String,
	<OutAttribute> ByRef errorMessage As String
) As IPrincipal
public:
static IPrincipal^ AuthenticateUser(
	String^ domain, 
	String^ userName, 
	String^ password, 
	[OutAttribute] String^% errorMessage
)
static member AuthenticateUser : 
        domain : string * 
        userName : string * 
        password : string * 
        errorMessage : string byref -> IPrincipal GSF.Identity.UserInfo.AuthenticateUser = function(domain, userName, password, errorMessage);
 View SourceParameters
- domain  String
 - Domain of user to authenticate.
 - userName  String
 - Username of user to authenticate.
 - password  String
 - Password of user to authenticate.
 - errorMessage  String
 - Error message returned, if authentication fails.
 
Return Value
IPrincipaltrue if the user credentials are authenticated successfully; otherwise false.
Example
             This example shows how to validate a user's credentials and retrieve an error message if validation fails: 
             
using System;
using GSF.Identity;
class Program
{
    static void Main(string[] args)
    {
        string domain = "XYZCorp";
        string username = "johndoe";
        string password = "password";
        string errorMessage;
        
        if (UserInfo.AuthenticateUser(domain, username, password, out errorMessage) is not null)
            Console.WriteLine("Successfully authenticated user \"{0}\\{1}\".", domain, username);
        else
            Console.WriteLine("Failed to authenticate user \"{0}\\{1}\" due to exception: {2}", domain, username, errorMessage);
        Console.ReadLine();
    }
}
See Also