예제 #1
0
def log_in(server, username, password):
    dn = ldap_util.get_user_dn(username)
    if not password:
        password = getpass.getpass("LDAP password: "******"no such authenticating user '{0}".format(opts.user)
        parser.error(msg)
    except ldap.INVALID_CREDENTIALS:
        parser.error("incorrect password")
예제 #2
0
def log_in(server, username, password):
    dn = ldap_util.get_user_dn(username)
    if not password:
        password = getpass.getpass("LDAP password: "******"no such authenticating user '{0}".format(opts.user)
        parser.error(msg)
    except ldap.INVALID_CREDENTIALS:
        parser.error("incorrect password")
예제 #3
0
def lookup_user(server, username, attributes=None):
    log = logging.getLogger()
    log.debug("lookup_user args: %r", locals())
    print "{0}: ".format(username)
    dn = ldap_util.get_user_dn(username)
    scope = ldap.SCOPE_BASE
    attrlist = attributes or None
    try:
        records = server.search_s(dn, scope, attrlist=attrlist)
    except ldap.NO_SUCH_OBJECT:
        print "    no such user"
        return
    if records:
        for dn, attrs in records:
            print "    {0}:".format(dn)
            for key, value in sorted(attrs.iteritems()):
                print "        {0}: {1!r}".format(key, value)
    else:
        print "    no results"
예제 #4
0
def lookup_user(server, username, attributes=None):
    log = logging.getLogger()
    log.debug("lookup_user args: %r", locals())
    print "{0}: ".format(username)
    dn = ldap_util.get_user_dn(username)
    scope = ldap.SCOPE_BASE
    attrlist = attributes or None
    try:
        records = server.search_s(dn, scope, attrlist=attrlist)
    except ldap.NO_SUCH_OBJECT:
        print "    no such user"
        return
    if records:
        for dn, attrs in records:
            print "    {0}:".format(dn)
            for key, value in sorted(attrs.iteritems()):
                print "        {0}: {1!r}".format(key, value)
    else:
        print "    no results"