Example external authorization script

Example authorization script for use with the Perforce IPLM LDAP integration.

#!/usr/bin/python

import sys

# use the ldap python module
# import ldap

# pi passes the newline separated string
# "<username>\n<password>" over stdin
# this line will insert the username
# and password in the first two elements
# of the list 'mylist'

mylist=sys.stdin.read().split('\n')

# following section is a test which writes
# the username/password
# passed in from pi in the file /tmp/x
# these lines shouldn't be included in
# an actual authorization script.

# test to verify user/password is loaded:
# fl = open("/tmp/x", "w")
# fl.write("username="+mylist[0]+'\n')
# fl.write("password="+mylist[1]+'\n')
# fl.close()
# test ends here

# once the username and password are retrieved
# an ldap call should be made to verify they are correct

# LDAP call here

# if the username/password is correct then we should
# return a value of 0 to pi:
sys.exit(0)

# if the username and password are incorrect we
# should return a value other than 0 to pi:
# sys.exit(1)