Package: pbook
PBook=====LDAP phone book written in Python.Output examples---------------Default search result:$ pbook johnFirst name: JohnLast name: DoeE-mail: john.doe@example.comTelephone: +44123456789123Title: Placeholder nameCity: LondonUser name: jdoeDefault search results using pattern search filter recognition:$ pbook 789First name: JohnLast name: DoeE-mail: john.doe@example.comTelephone: +44123456789123Title: Placeholder nameCity: LondonUser name: jdoeDefault search result using LDAP field name decoration:$ pbook -d johngivenName: Johnsn: Doemail: john.doe@example.comtelephoneNumber: +44123456789123title: Placeholder namel: Londonuid: jdoeSearch result using custom search filter:$ pbook -S 'title=place*'First name: JohnLast name: DoeE-mail: john.doe@example.comTelephone: +44123456789123Title: Placeholder nameCity: LondonUser name: jdoeSearch result using the `name` search template:$ pbook -s name doeFirst name: JohnLast name: DoeE-mail: john.doe@example.comTelephone: +44123456789123Title: Placeholder nameCity: LondonUser name: jdoeSearch result using the `multicolumn` template:$ pbook -t multicolumn johnLast name | First name |                         E-mail |            Telephone-----------+------------+--------------------------------+----------------------Doe |       John |           john.doe@example.com |    +44123456789, 123Requirements------------* Python 2.7* Python LDAP module (http://www.python-ldap.org)Installation------------In order to install pbook, just download the code, make sure all dependenciesare installed (see [Requirements](https://github.com/jtyr/pbook#requirements)above) and configure it:$ git clone https://github.com/jtyr/pbook.git$ cd pbook$ chmod +x ./pbook$ # edit the pbook.conf file$ ./pbook -c ./pbook.conf johnOr it's possible to use the Python setup script:$ git clone https://github.com/jtyr/pbook.git$ cd pbook$ python ./setup.py install$ # edit the /etc/pbook.conf file$ pbook johnConfiguration-------------Look at the `pbook.conf` for a full configuration example. The configurationcan be defined globally (`/etc/pbook.conf`), per user (`~/.pbook`) or specifiedby an option on the command line (`pbook -c /path/to/pbook.conf john`). Theconfiguration file is composed of the following 6 sections:**connection**In this section we configure the LDAP server connection. Server name, port andconnection protocol is determined from the `uri` parameter. Password can beeither defined in clear text or, if the value is set to `-1`, the user will beprompted. The recommended approach is to configure `ldapsearch` correctlyfirst, and then re-use the parameters in this section. Example of the`ldapsearch` command:$ ldapsearch -H ldaps://ldap.example.com -D uid=jdoe,ou=Users,dc=example,dc=com -b ou=Users,dc=example,dc=com -W uid=jdoeFrom this command the configuration would be:[connection]uri=ldaps://ldap.example.com:636base_dn=ou=Users,dc=example,dc=combind_dn=uid=jdoe,ou=Users,dc=example,dc=compassword=-1**search_template**In this section we configure the LDAP search filter. The default search filteris defined by `_default` (e.g. `_default=nane`) or by the command line option`-s` (e.g. `pbook -s name john`). Example of search template definition:[search_template]_default=namename=(|(givenName=*%s*)(sn=*%s*))It's also possible to specify a custom search filter on the command line withthe option `-S` (e.g. `pbook -S 'uid=%s' jdoe` or `pbook -S 'uid=jdoe'`).**search_pattern**On top of the default search filter, there is also pattern search filterrecognition. This allows the configuration of a specific search filter based ona specified search string. For example, if all telephone numbers in the companyhave the same format except for the last 3 digits, we can define a patternwhich will search the telephone number if the search string is a 3-digitnumber:[search_pattern](\d{3})=(telephoneNumber=+44123456\1)Then we can search for a phone number `+44123456789` by executing `pbook 789`.**label**This section provides translation of the LDAP fields into a human readableformat, which is then used in the `pbook` output. For example `givenName=Firstname` translates the `givenName` field to `First name` label.  It's mandatoryto have a label for every field used in the template (read more bellow).Example of label definition:[label]givenName=First namesn=Last nametelephoneNumber=Telephone**template**The default template is specified by the `_default` parameter (e.g.`_default=basic`) or by the command line option `-t` (e.g. `pbook -t basicjohn`). Templates can be defined in two forms. The first of which is a simplelist of LDAP fields which will be translated into a line-separated list oflabels and values. For example the following template:[template]_default=basicbasic=(givenName,sn)generates the following output:First name: JohnLast name: DoeThe second form is using the `printf` string format. For example the followingtemplate:multicolumn=%(givenName)10.10s | %(sm)10.10sgenerates the following output:John |        DoeIt is possible to specify a header for the output by a parameter named the samethe template itself appended with `_header`. The header can refer to labels bythe label name prefixed with two underscores. The header for the above examplecould look like this:multicolumn_header=%(__givenName)10.10s | %(__sn)10.10s\n-----------+-----------and the output would then look like this:First name |  Last name-----------+-----------John |        Doe**output**This section is optional and may contain definition of replacements for LDAPvalues. In other words, it allows the manipulation of values coming from theLDAP search by using a regular expression. For example, if we want to displayonly last three digits of the `telephoneNumber`, we would define the followingoutput replacement:[output]telephoneNumber=.*(\d{3})$;\1License-------This software is licensed by the MIT License which can be found in the file[LICENSE](http://github.com/jtyr/pbook/blob/master/LICENSE).