了解 Python-ldap 中的命名冲突

Understanding Naming Violations in Python-ldap

我有一组差异需要 "saved"(它们都是新记录)。以下代码用于提交更改集:

def commit(self):
    l = ldap.initialize(self.ldapURL)
    l.simple_bind_s(self.ldapUser,self.ldapPass)
    for dn,ldif in self.ldapAdds.iteritems():
        try:
            print json.dumps(ldif,indent=4)
            l.add_s(dn,ldif)
            print "a",
        except ldap.ALREADY_EXISTS:
            pass

    for dn,ldif in self.ldapMods.iteritems():
        l.modify_s(dn,ldif)
        print "m",
    print ""
    l.unbind_s()
    self.ldapAdds = dict()
    self.ldapMods = dict()

不幸的是,我收到以下错误:

Traceback (most recent call last): File "./ldapUpdate.py", line 868, in lMods.commit() File "./ldapUpdate.py", line 769, in commit l.add_s(dn,ldif) File "/sites/utils/Python/lib/python2.7/site-packages/ldap/ldapobject.py", line 216, in add_s return self.add_ext_s(dn,modlist,None,None) File "/sites/utils/Python/lib/python2.7/site-packages/ldap/ldapobject.py", line 202, in add_ext_s resp_type, resp_data, resp_msgid, resp_ctrls = self.result3(msgid,all=1,timeout=self.timeout) File "/sites/utils/Python/lib/python2.7/site-packages/ldap/ldapobject.py", line 519, in result3 resp_ctrl_classes=resp_ctrl_classes File "/sites/utils/Python/lib/python2.7/site-packages/ldap/ldapobject.py", line 526, in result4 ldap_result = self._ldap_call(self._l.result4,msgid,all,timeout,add_ctrls,add_intermediates,add_extop) File "/sites/utils/Python/lib/python2.7/site-packages/ldap/ldapobject.py", line 108, in _ldap_call result = func(*args,**kwargs) ldap.NAMING_VIOLATION: {'info': "naming attribute 'src' has no equality matching rule", 'desc': 'Naming violation'}

失败的 ldiff 记录如下所示:

[
    [  "src",   "ecare/ecare-self.ear" ], 
    [  "modname",  "ecare-self"  ], 
    [  "dest",   "/sites/MODULES/ecare/ecare-self.ear"], 
    [  "objectClass",  [  "ctlapp", "ctlmodule", "top" ] ], 
    [  "action",  "rsync" ], 
    [  "depot",  "DEPOT" ]
]

SLAPD 不喜欢的 "src" 字段是什么?有人对 NAMING_VIOLATIONs 有更深入的了解吗?

"src" 在架构中有这个定义

attributetype ( 1.3.6.4.2.7888.5.1.16 NAME 'src'
                SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
                X-ORIGIN 'user defined' )

"ctlapp" 在架构中有这个定义

objectclass ( 1.3.6.4.2.7888.5.1.22 NAME 'ctlapp'
                DESC 'ATT deployable component'
                SUP ctlmodule STRUCTURAL
                MUST ( src $ depot $ dest $ action )
                X-ORIGIN 'user defined' )

"src" 的正确模式定义应该是:

attributetype ( 1.3.6.4.2.7888.5.1.16 NAME 'src'
                DESC 'ATT source path'
                EQUALITY caseExactMatch
                SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{512}
                X-ORIGIN 'user defined' )

缺少 "equality" 子句。这就是 NAMING_VIOLATION 解释的内容。