Exemplo n.º 1
0
def get_directory_at(socket, user, password, basedn=None, use_tls=False,
                     server_type=STANDARD_LDAP):
    res = LDAPResource()
    res.server = socket
    res.login = user
    res.password = password
    res.basedn = basedn
    res.tls = use_tls
    res.server_type = server_type

    directory = Directory()
    directory.connect(res)

    return directory
Exemplo n.º 2
0
def get_directory_at(socket,
                     user,
                     password,
                     basedn=None,
                     use_tls=False,
                     server_type=STANDARD_LDAP):
    res = LDAPResource()
    res.server = socket
    res.login = user
    res.password = password
    res.basedn = basedn
    res.tls = use_tls
    res.server_type = server_type

    directory = Directory()
    directory.connect(res)

    return directory
Exemplo n.º 3
0
def get_directory():
    global _directory

    if not _directory:
        res = LDAPResource()
        res.server = config.LDAP_SOCKET
        res.login = config.LDAP_LOGIN
        res.password = config.LDAP_PASSWORD
        res.tls = getattr(config, 'LDAP_TLS', False)
        res.basedn = config.LDAP_BASEDN

        _directory = Directory()
        _directory.connect(res)

    return _directory
Exemplo n.º 4
0
from pumpkin.resource import LDAPResource
from pumpkin.directory import Directory


SERVER = 'ldap://localhost:1389'
BASEDN = 'dc=company,dc=com'

LDAP_RES = LDAPResource()
LDAP_RES.server = SERVER
LDAP_RES.login = '******'
LDAP_RES.password = '******'
LDAP_RES.TLS = False
LDAP_RES.basedn = BASEDN

LDAP_CONN = Directory()
LDAP_CONN.connect(LDAP_RES)


ANON_RES = LDAPResource()
ANON_RES.server = SERVER
ANON_RES.TLS = False
ANON_RES.basedn = BASEDN

ANON_CONN = Directory()
ANON_CONN.connect(ANON_RES)
Exemplo n.º 5
0
from pumpkin.resource import LDAPResource, ACTIVE_DIRECTORY_LDAP
from pumpkin.directory import Directory
from pumpkin.contrib.models.ad import GenericObject, OrganizationalUnit, Group, User

import ldap

AD_RES = LDAPResource()
AD_RES.server_type = ACTIVE_DIRECTORY_LDAP
AD_RES.server = 'ldap://DOMAIN_NAME'
AD_RES.login = '******'
AD_RES.password = '******'
AD_RES.basedn = 'dc=DOMAIN,dc=NAME'

AD_CONN = Directory()
AD_CONN.connect(AD_RES)

def test_dump_objects():
    print "All Objects:"
    for obj in AD_CONN.search(GenericObject, basedn='CN=Users,'+AD_RES.basedn):
        print "\t%s"%(obj)
        print "\t\t%s: %s"%('guid', obj.guid)

    print "Organizational Units:"
    for obj in AD_CONN.search(OrganizationalUnit, basedn='CN=Users,'+AD_RES.basedn):
        print "\t%s"%(obj)
        print "\t\t%s: %s"%('name', obj.name)

    print "Groups:"
    for obj in AD_CONN.search(Group, basedn='CN=Users,'+AD_RES.basedn):
        print "\t%s"%(obj)
        print "\t\t%s: %s"%('name', obj.name)