Click or drag to resize

UserInfoDefinePrivilegedAccount Method

Defines the credentials of a privileged domain account that can be used for impersonation prior to the retrieval of user information from the Active Directory.

Namespace: GSF.Identity
Assembly: GSF.Core (in GSF.Core.dll) Version: 2.4.258-beta+f8b6aa3dbfe0b4cc2b0b0760dd5d2a3dd4f59d09
Syntax
public void DefinePrivilegedAccount(
	string domain,
	string username,
	string password
)
View Source

Parameters

domain  String
Domain of privileged domain user account.
username  String
Username of privileged domain user account.
password  String
Password of privileged domain user account.
Example
This example shows how to define the identity of the user to be used for retrieving information from Active Directory:
C#
using System;
using GSF.Identity;

class Program
{
    static void Main(string[] args)
    {
        using (UserInfo user = new UserInfo("XYZCorp\\johndoe"))
        {
            // Define the identity to use for retrieving Active Directory information.
            // Persist identity credentials encrypted to the config for easy access.
            user.PersistSettings = true;
            user.DefinePrivilegedAccount("XYZCorp", "admin", "Passw0rd");

            // Retrieve and display user information from Active Directory.
            Console.WriteLine(string.Format("First Name: {0}", user.FirstName));
            Console.WriteLine(string.Format("Last Name: {0}", user.LastName));
            Console.WriteLine(string.Format("Middle Initial: {0}", user.MiddleInitial));
            Console.WriteLine(string.Format("Email Address: {0}", user.Email));
            Console.WriteLine(string.Format("Telephone Number: {0}", user.Telephone));
        }

        Console.ReadLine();
    }
}
See Also