python - Python ldap3 创建组
问题描述
我是 python 和 ldap3 模块的新手。但是我想在特定的 OU 中创建一个 AD 组。如何才能做到这一点?
# import class and constants
from ldap3 import Server, Connection, ALL
# define the server
s = Server('servername', get_info=ALL) # define an unsecure LDAP server,
# define the connection
c = Connection(s, user='user_dn', password='user_password')
ou = "OU=Staff,OU=RU,DC=DOMAIN,DC=LOCAL"
groupname="ADM_Local"
description="local group for access to IPA"
如何ADM_Local
在定义的 ou 中添加组并将描述添加到组中?该文档没有说明它是如何完成的:https ://ldap3.readthedocs.io/tutorial_operations.html#create-an-entry
解决方案
您需要使用groupOfNames结构的 objectClass(或派生的)。请注意,根据您的 ldap 服务器实现,member
可能需要该属性来防止创建空组。
groupDN = 'cn=ADM_Local,ou=Staff,ou=RU,dc=domain,dc=local'
objectClass = 'groupOfNames'
attr = {
'cn': 'ADM_Local',
'member': 'uid=admin,ou=people,dc=domain,dc=local',
'description': 'local group for access to IPA'
}
c.add(groupDN , objectClass , attr)
推荐阅读
- php - PHP - preg_match():在字符串中搜索多个 unicode 字符不是重复的,实际阅读
- java - 如果我写了一个实现 Comparable 接口的类“Hello”的版本,那么这个版本的 Hello 类是“IS-A Hello”还是“IS-A Comparable”
- ajax - AJAX如何将php函数的值传递给AJAX动作调用
- google-cloud-dataflow - 数据流水印概念
- keychain - 从 CA 请求证书时出现“未知错误 = 1”
- openssl - 如何使用 Openssl:ECDSA 获取它的 pubkey
- c# - FileSavePicker 可以在 UWP 后台进程中使用吗?
- http - 由于 http 代码 -1,无法通过 http 调用向服务器发送数据
- php - php递归函数出错异常
- yocto - 介子无法从源代码构建 systemd:找不到“getent”