| 1 |
# (C) Copyright 2003 Nuxeo SARL <http://nuxeo.com> |
|---|
| 2 |
# |
|---|
| 3 |
# This program is free software; you can redistribute it and/or modify |
|---|
| 4 |
# it under the terms of the GNU General Public License version 2 as published |
|---|
| 5 |
# by the Free Software Foundation. |
|---|
| 6 |
# |
|---|
| 7 |
# This program is distributed in the hope that it will be useful, |
|---|
| 8 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 9 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 10 |
# GNU General Public License for more details. |
|---|
| 11 |
# |
|---|
| 12 |
# You should have received a copy of the GNU General Public License |
|---|
| 13 |
# along with this program; if not, write to the Free Software |
|---|
| 14 |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
|---|
| 15 |
# 02111-1307, USA. |
|---|
| 16 |
# |
|---|
| 17 |
# $Id: LDAPBackingDirectorypatch.py,v 1.0 2007/10/30 15:35:43 Souleymane BA && Omar MAR $ |
|---|
| 18 |
"""LDAPBackingDirectory |
|---|
| 19 |
|
|---|
| 20 |
This is a simple but efficient version of an LDAP Directory. |
|---|
| 21 |
It has no dependencies besides the ldap module. |
|---|
| 22 |
|
|---|
| 23 |
In this directory the id is always the dn. |
|---|
| 24 |
""" |
|---|
| 25 |
|
|---|
| 26 |
from logging import getLogger |
|---|
| 27 |
|
|---|
| 28 |
import re |
|---|
| 29 |
import sys |
|---|
| 30 |
|
|---|
| 31 |
from Globals import InitializeClass |
|---|
| 32 |
from AccessControl import ClassSecurityInfo |
|---|
| 33 |
from OFS.Image import Image |
|---|
| 34 |
from OFS.Cache import Cacheable |
|---|
| 35 |
|
|---|
| 36 |
from Products.CPSUtil.ssha import sshaDigest |
|---|
| 37 |
from Products.CPSUtil.testing.environment import isTestingEnvironment |
|---|
| 38 |
|
|---|
| 39 |
from Products.CPSSchemas.StorageAdapter import BaseStorageAdapter |
|---|
| 40 |
from Products.CPSSchemas.Field import ValidationError |
|---|
| 41 |
|
|---|
| 42 |
from Products.CPSDirectory.BaseDirectory import BaseDirectory |
|---|
| 43 |
from Products.CPSDirectory.BaseDirectory import AuthenticationFailed |
|---|
| 44 |
from Products.CPSDirectory.BaseDirectory import ConfigurationError |
|---|
| 45 |
from Products.CPSDirectory.BaseDirectory import _replaceProperty |
|---|
| 46 |
|
|---|
| 47 |
from Products.CPSDirectory.interfaces import IDirectory |
|---|
| 48 |
#from Products.CPSDirectory.LDAPDirectory import LDAPDirectory |
|---|
| 49 |
from Products.CPSDirectory.LDAPBackingDirectory import isCanonicalDN |
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
from zope.interface import implements |
|---|
| 53 |
|
|---|
| 54 |
def adie_checkUnderBase(self, dn): |
|---|
| 55 |
"""Check that dn is under the base.""" |
|---|
| 56 |
URL=dn |
|---|
| 57 |
URL=URL.split(" ") |
|---|
| 58 |
print URL |
|---|
| 59 |
i=0 |
|---|
| 60 |
URL_Valid='' |
|---|
| 61 |
for i in range(len(URL)): |
|---|
| 62 |
URL_Valid+=URL[i] |
|---|
| 63 |
dn=URL_Valid |
|---|
| 64 |
if not isCanonicalDN(dn): |
|---|
| 65 |
raise KeyError("DN '%s' is not canonical" % dn) |
|---|
| 66 |
if not (','+dn).endswith(','+self.ldap_base): |
|---|
| 67 |
raise ValueError("DN '%s' must be under base '%s'" % |
|---|
| 68 |
(dn, self.ldap_base)) |
|---|
| 69 |
|
|---|
| 70 |
from Products.CPSDirectory import LDAPBackingDirectory |
|---|
| 71 |
LDAPBackingDirectory.checkUnderBase = adie_checkUnderBase |
|---|