forked from uncloud/uncloud
42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
import ldap
|
|
# from django.conf import settings
|
|
|
|
AUTH_LDAP_SERVER_URI = "ldaps://ldap1.ungleich.ch,ldaps://ldap2.ungleich.ch"
|
|
AUTH_LDAP_BIND_DN="uid=django-create,ou=system,dc=ungleich,dc=ch"
|
|
AUTH_LDAP_BIND_PASSWORD="kS#e+v\zjKn]L!,RIu2}V+DUS"
|
|
# AUTH_LDAP_USER_SEARCH = LDAPSearch("dc=ungleich,dc=ch",
|
|
# ldap.SCOPE_SUBTREE,
|
|
# "(uid=%(user)s)")
|
|
|
|
|
|
|
|
ldap_object = ldap.initialize(AUTH_LDAP_SERVER_URI)
|
|
cancelid = ldap_object.bind(AUTH_LDAP_BIND_DN, AUTH_LDAP_BIND_PASSWORD)
|
|
|
|
res = ldap_object.search_s("dc=ungleich,dc=ch", ldap.SCOPE_SUBTREE, "(uid=nico)")
|
|
print(res)
|
|
|
|
# class LDAP(object):
|
|
# """
|
|
# Managing users in LDAP
|
|
|
|
# Requires the following settings?
|
|
|
|
# LDAP_USER_DN: where to create users in the tree
|
|
|
|
# LDAP_ADMIN_DN: which DN to use for managing users
|
|
# LDAP_ADMIN_PASSWORD: which password to used
|
|
|
|
# This module will reuse information from djagno_auth_ldap, including:
|
|
|
|
# AUTH_LDAP_SERVER_URI
|
|
|
|
# """
|
|
# def __init__(self):
|
|
# pass
|
|
|
|
# def create_user(self):
|
|
# pass
|
|
|
|
# def change_password(self):
|
|
# pass
|