[英]How to install a LDAP schema with python-ldap?
import ldap.modlist
import ldif
with open("myschema.ldif") as fd:
parser = ldif.LDIFRecordList(fd)
parser.parse()
for dn, entry in parser.all_records:
add_modlist = ldap.modlist.addModlist(entry)
conn.add_s(dn, add_modlist) # where 'conn' is a LDAP connection
简短的回答是@azmeuk 之前写过的。
长答案是:这取决于 LDIF 文件的格式。 如果它包含修改语句,则您无法使用 python-ldap 轻松解析该文件。
请检查我在Process LDIF modify records with python-ldap 中的问题,看看我在说什么。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.