diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2008-09-24 19:56:07 +0000 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2008-09-24 19:56:07 +0000 |
commit | 63a26bd604c3d1421d07fe8737953101409e0fad (patch) | |
tree | 3515ec30858e980f62bc94512644b12418b48a74 /ipalib/conn.py | |
parent | f8bb60f02dc3cbb48c2cc6305e095e6936f5a0d6 (diff) | |
download | freeipa.git-63a26bd604c3d1421d07fe8737953101409e0fad.tar.gz freeipa.git-63a26bd604c3d1421d07fe8737953101409e0fad.tar.xz freeipa.git-63a26bd604c3d1421d07fe8737953101409e0fad.zip |
345: Moved server code from Rob into ipa_server/ package
Diffstat (limited to 'ipalib/conn.py')
-rw-r--r-- | ipalib/conn.py | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/ipalib/conn.py b/ipalib/conn.py deleted file mode 100644 index f8f5306f..00000000 --- a/ipalib/conn.py +++ /dev/null @@ -1,72 +0,0 @@ -# Authors: Rob Crittenden <rcritten@redhat.com> -# -# Copyright (C) 2008 Red Hat -# see file 'COPYING' for use and warranty information -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; version 2 only -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# - -import krbV -import threading -import ldap -import ldap.dn -from ipalib import ipaldap - -context = threading.local() - -class IPAConn: - def __init__(self, host, port, krbccache, debug=None): - self._conn = None - - # Save the arguments - self._host = host - self._port = port - self._krbccache = krbccache - self._debug = debug - - self._ctx = krbV.default_context() - - ccache = krbV.CCache(name=krbccache, context=self._ctx) - cprinc = ccache.principal() - - self._conn = ipaldap.IPAdmin(host,port,None,None,None,debug) - - # This will bind the connection - try: - self._conn.set_krbccache(krbccache, cprinc.name) - except ldap.UNWILLING_TO_PERFORM, e: - raise e - except Exception, e: - raise e - - def __del__(self): - # take no chances on unreleased connections - self.releaseConn() - - def getConn(self): - return self._conn - - def releaseConn(self): - if self._conn is None: - return - - self._conn.unbind_s() - self._conn = None - - return - -if __name__ == "__main__": - ipaconn = IPAConn("localhost", 389, "FILE:/tmp/krb5cc_500") - x = ipaconn.getConn().getEntry("dc=example,dc=com", ldap.SCOPE_SUBTREE, "uid=admin", ["cn"]) - print "%s" % x |