Add possibility to enter password with a prompt

This commit is contained in:
Benjamin Renard 2016-06-28 23:54:44 +02:00
parent 07048d3e26
commit 49337ceeed
1 changed files with 5 additions and 1 deletions

View File

@ -39,6 +39,7 @@ import ldap
import ldap.modlist as modlist
import logging
import sys
import getpass
from optparse import OptionParser
@ -68,7 +69,7 @@ parser.add_option( "-P", "--pwd",
dest="pwd",
action="store",
type='string',
help="LDAP bind password")
help="LDAP bind password. Specify '-P -' to ask for a prompt.")
parser.add_option( "-b", "--basedn",
dest="basedn",
@ -153,6 +154,9 @@ if options.touch and not options.attrs:
logging.info('Force option attrs on touch mode')
options.attrs=True
if options.pwd == '-':
options.pwd=getpass.getpass()
excl_attrs=[]
if options.excl_attrs:
for ex in options.excl_attrs.split(','):