mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Got new ldap connection working using Connectible.connect()
This commit is contained in:
committed by
Rob Crittenden
parent
231f0bd65a
commit
a0aebd46a1
@@ -28,8 +28,8 @@ import ldap as _ldap
|
||||
from ipalib import api
|
||||
from ipalib import errors
|
||||
from ipalib.crud import CrudBackend
|
||||
from ipaserver import servercore
|
||||
from ipaserver import ipaldap
|
||||
from ipaserver import servercore, ipaldap
|
||||
import krbV
|
||||
|
||||
|
||||
class ldap(CrudBackend):
|
||||
@@ -41,11 +41,16 @@ class ldap(CrudBackend):
|
||||
self.dn = _ldap.dn
|
||||
super(ldap, self).__init__()
|
||||
|
||||
def create_connection(self, ccache=None):
|
||||
return 'The LDAP connection.'
|
||||
def create_connection(self, ccache):
|
||||
conn = ipaldap.IPAdmin(self.env.ldap_host, self.env.ldap_port)
|
||||
principle = krbV.CCache(
|
||||
name=ccache, context=krbV.default_context()
|
||||
).principal().name
|
||||
conn.set_krbccache(ccache, principle)
|
||||
return conn
|
||||
|
||||
def destroy_connection(self):
|
||||
pass
|
||||
self.conn.unbind_s()
|
||||
|
||||
def make_user_dn(self, uid):
|
||||
"""
|
||||
|
||||
@@ -338,7 +338,7 @@ class ra(Backend):
|
||||
|
||||
def __get_ca_chain(self):
|
||||
headers = {"Content-type": "application/x-www-form-urlencoded"}
|
||||
conn = httplib.HTTPConnection(self.ca_host+":"+self.ca_port)
|
||||
conn = httplib.HTTPConnection(self.ca_host, self.ca_port)
|
||||
conn.request("POST", "/ca/ee/ca/getCertChain", None, headers)
|
||||
response = conn.getresponse()
|
||||
api.log.debug("IPA-RA: response.status: %d response.reason: '%s'" % (response.status, response.reason))
|
||||
|
||||
@@ -46,11 +46,12 @@ class xmlserver(Executioner):
|
||||
Also see the `ipalib.rpc.xmlclient` plugin.
|
||||
"""
|
||||
|
||||
def marshaled_dispatch(self, data):
|
||||
def marshaled_dispatch(self, data, ccache):
|
||||
"""
|
||||
Execute the XML-RPC request in contained in ``data``.
|
||||
"""
|
||||
try:
|
||||
self.create_context(ccache=ccache)
|
||||
(params, name) = xml_loads(data)
|
||||
(args, options) = params_2_args_options(params)
|
||||
response = (self.execute(name, *args, **options),)
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
import ldap
|
||||
import string
|
||||
import re
|
||||
from ipaserver.context import context
|
||||
from ipalib.request import context
|
||||
from ipaserver import ipaldap
|
||||
import ipautil
|
||||
from ipalib import errors
|
||||
@@ -86,7 +86,7 @@ def get_entry (base, scope, searchfilter, sattrs=None):
|
||||
"""
|
||||
ent=""
|
||||
|
||||
ent = context.conn.getConn().getEntry(base, scope, searchfilter, sattrs)
|
||||
ent = context.ldap.conn.getEntry(base, scope, searchfilter, sattrs)
|
||||
|
||||
return convert_entry(ent)
|
||||
|
||||
@@ -117,7 +117,7 @@ def get_list (base, searchfilter, sattrs=None, scope=ldap.SCOPE_SUBTREE):
|
||||
"""
|
||||
entries = []
|
||||
|
||||
entries = context.conn.getConn().getList(base, scope, searchfilter, sattrs)
|
||||
entries = context.ldap.conn.getList(base, scope, searchfilter, sattrs)
|
||||
|
||||
return map(convert_entry, entries)
|
||||
|
||||
@@ -252,22 +252,22 @@ def update_entry (entry, remove_keys=[]):
|
||||
# FIXME: return a missing DN error message
|
||||
raise e
|
||||
|
||||
return context.conn.getConn().updateEntry(moddn, oldentry, newentry)
|
||||
return context.ldap.conn.updateEntry(moddn, oldentry, newentry)
|
||||
|
||||
def add_entry(entry):
|
||||
"""Add a new entry"""
|
||||
return context.conn.getConn().addEntry(entry)
|
||||
return context.ldap.conn.addEntry(entry)
|
||||
|
||||
def delete_entry(dn):
|
||||
"""Remove an entry"""
|
||||
return context.conn.getConn().deleteEntry(dn)
|
||||
return context.ldap.conn.deleteEntry(dn)
|
||||
|
||||
# FIXME, get time and search limit from cn=ipaconfig
|
||||
def search(base, filter, attributes, timelimit=1, sizelimit=3000):
|
||||
"""Perform an LDAP query"""
|
||||
try:
|
||||
timelimit = float(timelimit)
|
||||
results = context.conn.getConn().getListAsync(base, ldap.SCOPE_SUBTREE,
|
||||
results = context.ldap.conn.getListAsync(base, ldap.SCOPE_SUBTREE,
|
||||
filter, attributes, 0, None, None, timelimit, sizelimit)
|
||||
except ldap.NO_SUCH_OBJECT:
|
||||
raise errors.NotFound
|
||||
@@ -322,7 +322,7 @@ def get_ipa_config():
|
||||
return config
|
||||
|
||||
def modify_password(dn, oldpass, newpass):
|
||||
return context.conn.getConn().modifyPassword(dn, oldpass, newpass)
|
||||
return context.ldap.conn.modifyPassword(dn, oldpass, newpass)
|
||||
|
||||
def mark_entry_active (dn):
|
||||
"""Mark an entry as active in LDAP."""
|
||||
|
||||
Reference in New Issue
Block a user