Normalizing usernames from printer usage

On some systems, when user's print their username contains the full context of their name in the domain. An example of where this occurs is when using Novell's print services. In this situation the full context of the username (e.g. jsmith.dept.orgname) is passed through to PaperCut. The print usage will then be tracked against the full context username rather than the standard username (e.g. jsmith).

PaperCut NG can be configured to extract the username component of the full username with context. To do this:

  1. Log into the PaperCut NG admin pages
  2. Go to the Options tab
  3. Press the Config Editor (Advanced) actions link on the left.
  4. Search for the system.normalize-network-username-regex config key.
  5. Enter the regular expression to filter the username and press the Update button next to the value. For example regular expressions, see below.

How Username Filter Regular Expressions Work

Regular expressions are a powerful way to search text, however they can be quite complicated, so some example have been listed below. For more information regular expressions see the Regular expression syntax reference and the Regular expression tutorial.

The username filter extracts the username from the first matching regular expression group. A regular expression group is surrounded by parenthesis. e.g. (). So the component of the regular expression that matches the username should be surrounded in parenthesis.

Example Regular Expressions

Example 1

To filter username like jsmith.dept.orgname and extract the username jsmith user the following regex:

    ^([^\.]+)

In words this means: from the start of the string, match and extract one or more characters, as long as the character is not a . (period / full-stop). So this matches everything up to the first . character.

Example 2

Novell networks often set the print usersname to something like: .jsmith.dept.orgname (note the leading . character).

To filter username like .jsmith.dept.orgname and extract the username jsmith user the following regex:

    ^\.([^\.]+)

In words this means: from the start of the string, match a single ., then match and extract one or more characters, as long as the character is not a . (period / full-stop). So this matches everything up to the first . character.

Example 3

To filter username like prefix.jsmith.dept.orgname and extract the username jsmith user the following regex:

    ^prefix\.([^\.]+)

In words this means: from the start of the string, match prefix., then match and extract one or more characters, as long as the character is not a . (period / full-stop). So this matches everything between prefix. up to the first . character.

Example 4

To filter usernames that appear both like .jsmith.dept.orgname OR jsmith\DEPT\ORGNAME use the following regex:

    ^\.?([^\.\\]+)

Categories: Users, PaperCut NG and PaperCut ChargeBack 7+


Keywords: Novell Netware NDPS iPrint eDirectory normalise, normalization

Page last modified on April 14, 2009, at 11:08 PM