module 'ldap' has no attribute 'initialize'
时间: 2023-11-15 13:04:59 浏览: 57
你需要将`ldap.open`改成`ldap.initialize()`,因为在较新的版本中,`open`已经被弃用了。你可以参考以下代码:
```
import ldap
l = ldap.initialize("ldap://my_ldap_server.my_domain")
l.simple_bind_s("","")
l.search_s("o=My Organisation, c=AU", ldap.SCOPE_SUBTREE, "objectclass=*")
```
相关问题
ldapmodify ldap_initialize
ldap_modify 用于修改 LDAP 服务器中的条目。在使用该命令之前,需要先使用 ldap_initialize 来初始化 LDAP 连接。
ldap_initialize 函数用于初始化 LDAP 连接,并返回一个 LDAP 结构体指针,该指针用于后续的 LDAP 操作。
示例代码如下:
```
#include <stdio.h>
#include <ldap.h>
int main() {
LDAP *ld;
int result;
result = ldap_initialize(&ld, "ldap://localhost:389");
if (result != LDAP_SUCCESS) {
fprintf(stderr, "ldap_initialize: %s\n", ldap_err2string(result));
return 1;
}
// 进行其他的 LDAP 操作,例如 ldap_bind, ldap_search, ldap_modify 等
ldap_unbind_ext_s(ld, NULL, NULL);
return 0;
}
```
在上面的示例中,首先调用 ldap_initialize 初始化了一个 LDAP 连接,并将连接信息存储在 ld 指针中。接下来可以使用 ld 进行其他的 LDAP 操作,例如 ldap_bind 进行身份验证,ldap_search 进行搜索操作,ldap_modify 进行修改操作等。最后使用 ldap_unbind_ext_s 关闭 LDAP 连接。
需要注意的是,ldap_initialize 函数的第一个参数是指向 LDAP 结构体指针的指针,第二个参数是 LDAP 服务器的 URL。函数执行成功后,*ld 将包含一个有效的 LDAP 连接指针。
希望以上信息能够帮助到你!如果还有其他问题,请随时提问。
member-of ldap attribute
The member-of LDAP attribute is used to show the group membership of an LDAP entry. It is a multi-valued attribute that contains the distinguished names (DNs) of the groups that the entry is a member of. This attribute is typically used in LDAP-based authentication and authorization systems to determine the permissions and access rights of users based on their group memberships. The member-of attribute is read-only and is maintained by the LDAP server, which automatically updates it when a user is added to or removed from a group.
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)