了解Python-ldap中的命名冲突

时间:2018-06-01 19:18:22

标签: python python-2.7 openldap ldap-query

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

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()

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

  

回溯(最近一次呼叫最后):文件" ./ ldapUpdate.py",第868行,   在       lMods.commit()文件" ./ ldapUpdate.py",第769行,提交       l.add_s(dn,ldif)File" /sites/utils/Python/lib/python2.7/site-packages/ldap/ldapobject.py",   第216行,在add_s中       return self.add_ext_s(dn,modlist,None,None)File" /sites/utils/Python/lib/python2.7/site-packages/ldap/ldapobject.py",   第202行,在add_ext_s中       resp_type,resp_data,resp_msgid,resp_ctrls = self.result3(msgstr,all = 1,timeout = self.timeout)文件   " /sites/utils/Python/lib/python2.7/site-packages/ldap/ldapobject.py" ;,   第519行,结果3       resp_ctrl_classes = resp_ctrl_classes文件" /sites/utils/Python/lib/python2.7/site-packages/ldap/ldapobject.py",   第526行,结果4       ldap_result = self._ldap_call(self._l.result4,msgid,all,timeout,add_ctrls,add_intermediates,add_extop)   文件   " /sites/utils/Python/lib/python2.7/site-packages/ldap/ldapobject.py" ;,   第108行,在_ldap_call中       result = func(* args,** kwargs)ldap.NAMING_VIOLATION:{' info':"命名属性' src'没有相等匹配规则",' desc':   '命名违规'}

失败的ldiff记录如下所示:

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

" src"是什么? SLAPD不喜欢哪个领域?有人对NAMING_VIOLATION有更深入的了解吗?

" SRC"在schema

中有这个定义
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"在schema

中有这个定义
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' )

1 个答案:

答案 0 :(得分:1)

“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' )

缺少“平等”条款。这就是NAMING_VIOLATION正在解释的内容。