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.UserAssembly: PM90SettingsAPI (in PM90SettingsAPI.dll) Version: 9.0.23.534 (9.0.23.534)
Syntax 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:
PMUserA new PMUser object, or null if not found
Exceptions 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);
if (user.Balance.Unlimited)
{
user.Balance.SetUnlimited(false);
}
user.Balance.SetBalance(10.0);
user.ColorRestriction.Enable();
user.PageCountRestriction.Enable(10,
new PMAction("New employees may only print 10 pages at a time",
PMAction.ActionType.Delete,
true,
true
));
Console.WriteLine("User {0} has a default balance of {1} and {2} restrictions enabled.",user.UserName,
user.Balance.Unlimited ? "Unlimited" : user.Balance.Currency.ToString("C"),
user.Restrictions.Count(res => res.Enabled));
}
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)
{
Console.WriteLine("API Error: " + ex.Message + ex.InnerException != null ? (", The inner exception message is: " + ex.InnerException.Message) : "");
}
See Also