Ticket #133: ldapplugin_tls.2.patch
| File ldapplugin_tls.2.patch, 2.4 kB (added by tizianomueller, 2 years ago) |
|---|
-
ldapplugin-0.10/ldapplugin/model.py
old new 33 33 'group_bind', 'store_bind', 34 34 'user_rdn', 'group_rdn' ] 35 35 36 LDAP_DIRECTORY_PARAMS = [ ' host', 'port', 'basedn',36 LDAP_DIRECTORY_PARAMS = [ 'uri', 'basedn', 37 37 'bind_user', 'bind_passwd', 38 38 'groupname', 'groupmember', 39 'groupattr', 'uidattr', 'permattr'] 39 'groupattr', 'uidattr', 'permattr', 40 'start_tls', 'cacertdir', 'cacertfile', 41 'keyfile','certfile'] 40 42 41 43 GROUP_PREFIX = '@' 42 44 … … 501 503 def __init__(self, log, bind=False, **ldap): 502 504 self.log = log 503 505 self.bind = bind 504 self.host = 'localhost' 505 self.port = 389 506 self.uri = 'ldap://localhost:389' 506 507 self.groupname = 'groupofnames' 507 508 self.groupmember = 'member' 508 509 self.groupattr = 'cn' … … 511 512 self.bind_user = None 512 513 self.bind_passwd = None 513 514 self.basedn = None 515 self.start_tls = False 516 self.cacertdir = '/etc/ssl/certs' 517 self.cacertfile = '' 518 self.keyfile = '' 519 self.certfile = '' 514 520 for k, v in ldap.items(): 515 521 self.__setattr__(k, v.encode('ascii')) 516 if not isinstance(self.port, int):517 self.port = int(self.port)518 522 if self.basedn is None: 519 523 raise TracError, "No basedn is defined" 520 524 … … 592 596 def _open(self): 593 597 """Open and optionnally bind a new connection to the LDAP directory""" 594 598 try: 595 self._ds = ldap.initialize( 'ldap://%s:%d/' % (self.host, self.port))599 self._ds = ldap.initialize(self.uri) 596 600 self._ds.protocol_version = ldap.VERSION3 601 self._ds.x_tls_cacertdir = self.cacertdir 602 self._ds.x_tls_cacertfile = self.cacertfile 603 self._ds.x_tls_keyfile = self.keyfile 604 self._ds.x_tls_certfile = self.certfile 605 606 if self.start_tls == 'true': 607 self.log.debug("Starting TLS encryption.") 608 self._ds.start_tls_s() 609 597 610 if self.bind: 598 611 if not self.bind_user: 599 612 raise TracError("Bind enabled but credentials not defined")
