Returns an Active Directory user object with all of its related Centrify-specific data given the path to the object.


IUser GetUserByPath(string path)


Specify the following parameter when using this method:

Parameter Description


The LDAP path or distinguished name of the user object you want to retrieve.

Return value

The user object as:



GetUserByPath throws an ArgumentException if the computer path is null or empty.


This method returns the user object using the LDAP path or distinguished name of the object. The LDAP path to a user object uses the following format:


The method returns the user object as Centrify.DirectControl.API.User.ObjectName. For example, if the Active Directory user account is Jae Smith and the LDAP path to the account is CN=Jae Smith, CN=Users, DC=ajax, DC=org, the method returns the user object as:

Centrify.DirectControl.API.User.Jae Smith


The following code sample illustrates using this method in a script:

string strUser = args[0];
if (string.IsNullOrEmpty(strUser))
    Console.WriteLine("User DN cannot be empty.");
// Obtain an active directory container object
// Cnfigure the test container
DirectoryEntry objRootDSE = new DirectoryEntry("LDAP://rootDSE");
DirectoryEntry objContainer = new DirectoryEntry("LDAP://" + strParent + "," +     objRootDSE.Properties["defaultNamingContext"].Value.ToString());
string strContainerDN = objContainer.Properties["DistinguishedName"].Value as string;

// Create a CIMS object to interact with AD
ICims cims = new Cims();

// Note the lack of the cims.connect function.'
// By default, this application will use the connection to domain controller
// and existing credentials from the computer already logged in.

IHierarchicalZone objZone =
cims.GetZoneByPath("cn=" + strZone + "," + strContainerDN) as IHierarchicalZone;
IUser objUser = cims.GetUserByPath(strUser);
if (objUser == null)
    Console.WriteLine("User " + strUser + " does not exist.");