Click or drag to resize
PMUserLookupUser Method
Looks up and returns a PMUser object for the user and domain specified. User will be added if it doesn't exist yet

Namespace: PM90SettingsAPI.User
Assembly: PM90SettingsAPI (in PM90SettingsAPI.dll) Version: 9.0.23.534 (9.0.23.534)
Syntax
C#
public static PMUser LookupUser(
	string userName,
	string domainName
)

Parameters

userName
Type: SystemString
The Active Directory Logon name of user
domainName
Type: SystemString
The domain name of user, null or empty assumes workgroup / local user

Return Value

Type: PMUser
A new PMUser object, or null if not found
Exceptions
ExceptionCondition
ArgumentExceptionInvalid or null userName
PMObjectNoFoundExceptionUser does not exist, or could not be found
PMServiceUnreachableExceptionThe PMTracking service isn't running, or is unreachable
PMDatabaseConnectionNotFoundExceptionNo database connection available on this system
PMDatabaseExceptionRepresents an database connection or syntax error that has occurred when processing an API request
PMExceptionUnexcpected exception has occurred, check inner exception
Remarks
This API call requires the Print Manager Plus tracking service to be running. Fully qualified domain name is recommended, however NetBIOS domain names may be convertable if the domain can be reached.
Examples
Getting a user and setting quota and restrictions
try
{
    PMUser user = PMUser.LookupUser("Administrator", "domain.local");

    Console.WriteLine("User Name                : " + user.UserName);
    Console.WriteLine("UserID                   : " + user.DatabaseID);
    Console.WriteLine("Full Name                : " + user.FullName);
    Console.WriteLine("Domain Name              : " + user.DomainName);


    //See if user's default balance is set to unlimited printing balance, turn this off
    if (user.Balance.Unlimited)
    {
        user.Balance.SetUnlimited(false);
    }

    //Grant user a quota of $10.00
    user.Balance.SetBalance(10.0);




    //Restriction user from printing color
    user.ColorRestriction.Enable();


    //Restriction user from printing more than 10 pages with a custom message and action
    user.PageCountRestriction.Enable(10, //Max Pages allowed

                                    new PMAction("New employees may only print 10 pages at a time",    //Custom message
                                        PMAction.ActionType.Delete,                                    //Delete job if met
                                        true,                                                          //Send user an email
                                        true                                                           //Send user a popup
                                        ));


    //Check current status
    Console.WriteLine("User {0} has a default balance of {1} and {2} restrictions enabled.",user.UserName, 

    //Check if balance is unlimited, or has an quota
    user.Balance.Unlimited ? "Unlimited" : user.Balance.Currency.ToString("C"), 

    //count enabled restrictions
    user.Restrictions.Count(res => res.Enabled));
}

//Error handling - See PM90SettingsAPI.Exceptions
catch (PMDatabaseConnectionNotFoundException)
{
    Console.WriteLine("No Print Manager Plus database connection exists on this system.");
}
catch(PMServiceUnreachableException)
{
    Console.WriteLine("The PMTracking service is not running, or is unreachable.");
}
catch (PMObjectNoFoundException)
{
    Console.WriteLine("The user could not be found or looked up successfully.");
}
catch (PMException ex)
{
    //other exceptions
    Console.WriteLine("API Error: " + ex.Message + ex.InnerException != null ? (", The inner exception message is: " + ex.InnerException.Message) : "");
}
See Also