Click or drag to resize
PMUser Class
Represents a user within the Print Manager Plus database and tracking system.
Inheritance Hierarchy

Namespace: PM90SettingsAPI.User
Assembly: PM90SettingsAPI (in PM90SettingsAPI.dll) Version: 9.0.23.534 (9.0.23.534)
Syntax
C#
public class PMUser : PMRestrictable

The PMUser type exposes the following members.

Methods
  NameDescription
Public methodDelete
Deletes a user from the User list making them inactive. Past reporting will remain available.
Public methodDisableRule
Disables the passed rule for this user if enabled.
Public methodEnableRule
Enables the rule for this user.
Public methodStatic memberGetUsers
Returns all active users within the Print Manager Plus database
Public methodStatic memberCode exampleLookupUser
Looks up and returns a PMUser object for the user and domain specified. User will be added if it doesn't exist yet
Public methodOverridePrimaryGroup
Overrides the primary group for the user
Public methodRefresh
Refreshes the user's information, balances, restrictions
Protected methodRefreshRestrictions
Refreshes restriction list applied to this object
(Inherited from PMRestrictable.)
Top
Properties
  NameDescription
Public propertyADField01
Current Custom AD field value and information for this user
Public propertyADField02
Current Custom AD field value and information for this user
Public propertyADField03
Current Custom AD field value and information for this user
Public propertyADField04
Current Custom AD field value and information for this user
Public propertyADField05
Current Custom AD field value and information for this user
Public propertyBalance
The default balance for the user.
Public propertyBalances
A list of all active balances
Public propertyBlackAndWhiteRestriction
The current black and white restriction on this object
(Inherited from PMRestrictable.)
Public propertyColorRestriction
The current Color restriction on this object
(Inherited from PMRestrictable.)
Public propertyCopiesRestriction
The current Copies restriction on this object
(Inherited from PMRestrictable.)
Public propertyDatabaseID
The user's unique database identifier
(Overrides PMRestrictableDatabaseID.)
Public propertyDayTimeRestriction
The current DayTime restriction on this object
(Inherited from PMRestrictable.)
Public propertyDomainName
The user's domain name. null for Local / Workgroup users
Public propertyDuplexRestriction
The current Duplex restriction on this object
(Inherited from PMRestrictable.)
Public propertyDuplicateRestriction
The current Duplicate restriction on this object
(Inherited from PMRestrictable.)
Public propertyFullName
The user's full name
Public propertyJobCostRestriction
The current Page Costrestriction on this object
(Inherited from PMRestrictable.)
Public propertyJobSizeRestriction
The current Job Size restriction on this object
(Inherited from PMRestrictable.)
Public propertyPageCountRestriction
The current Page Count restriction on this object
(Inherited from PMRestrictable.)
Public propertyPageSizeRestriction
The current PageSize restriction on this object
(Inherited from PMRestrictable.)
Public propertyPaidBalance
The default balance for the user.
Public propertyPrimaryGroup
Current Primary group of user
Public propertyRestrictions
Full list of all generic restrictions.
(Inherited from PMRestrictable.)
Public propertyRules
Returns all rules enabled on this user
Public propertyTitleRestriction
The current Title restriction on this object
(Inherited from PMRestrictable.)
Public propertyUserName
The user's logon name
Top
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