Normalizing usernames from printer usage

KB Home   |   Normalizing usernames from printer usage

On some systems, when users 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 can be configured to extract the username component of the full username with context. To do this:

  1. Log into the PaperCut 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. There is even an online regular expression tester available here.

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


Keywords: Novell Netware NDPS iPrint eDirectory normalise, normalisation, username normalisation

Comments

Share your findings and experience with other PaperCut users. Feel free to add comments and suggestions about this Knowledge Base article. Please don't use this for support requests.

Article last modified on December 18, 2013, at 12:27 AM
Printable View   |   Article History   |   Edit Article