- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我似乎无法使用针对 OpenLDAP 服务器的 ldap3 python 模块更改用户密码。有人问过类似的问题before但这是特定于 Active Directory 的。
我尝试过的:
from ldap3.extend.standard.modifyPassword import ModifyPassword
from ldap3.utils.hashed import hashed
password = hashed(HASHED_SALTED_SHA, password)
# or..
password = '{SASL}theuser@domain.com'
modify = ModifyPassword(
connection, user.entry_get_dn(), new_password=password)
resp = modify.send()
print(modify.result)
{'referrals': None, 'result': 0, 'description': 'success', 'type': 'extendedResp', 'message': '', 'responseName': None, 'new_password': None, 'dn': '', 'responseValue': None}
描述说成功,但实际上并没有修改密码。
我还尝试发送修改替换消息:
def modify_user_password(self, user, password):
dn = user.entry_get_dn()
hashed_password = hashed(HASHED_SALTED_SHA, 'MyStupidPassword')
changes = {
'userPassword': [(MODIFY_REPLACE, [hashed_password])]
}
logger.debug('dn: ' + dn)
logger.debug('changes: ' + str(changes))
success = self.engage_conn.modify(dn, changes=changes)
if success:
logger.debug('Changed password for: %s', dn)
print(self.engage_conn.result)
else:
logger.warn('Unable to change password for %s', dn)
logger.debug(str(self.engage_conn.result))
raise ValueError('stop')
该连接不是 SSL 连接。 AD 问题的答案要求连接通过 SSL。这也是 OpenLDAP 的要求吗?
编辑:
将 dn
更改为 user.entry_get_dn()
后,代码似乎在大约 90% 的时间内都有效。今天再次运行这些测试后,它似乎现在可以一致地工作了。我将这归因于没有在我的目录浏览器中查看新数据。
最佳答案
更改密码似乎按照文档中的描述进行,并在上面对我的问题的编辑中显示。为了将来引用,此代码似乎有效:
from ldap3 import (
HASHED_SALTED_SHA, MODIFY_REPLACE
)
from ldap3.utils.hashed import hashed
def modify_user_password(self, user, password):
dn = user.entry_get_dn()
hashed_password = hashed(HASHED_SALTED_SHA, password)
changes = {
'userPassword': [(MODIFY_REPLACE, [hashed_password])]
}
success = self.connection.modify(dn, changes=changes)
if not success:
print('Unable to change password for %s' % dn)
print(self.connection.result)
raise ValueError('Unable to change password')
澄清一些事情:
关于python - 使用 ldap3 库更改 OpenLDAP 中的用户密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39325089/
这是我第一次使用 LDAP。我已经在 ubuntu 机器上设置了一个 openldap,并在远程系统上设置了一个 ldap 浏览器(phpldapadmin)。我正在尝试向 cn=config 添加两
是否可以在 openldap 中为架构属性类型添加别名?任何人都可以提供命令行指令来完成此操作吗? 例如, Description RFC2256: Telephone Number OID 2.5.
我尝试在 OpenLDAP 中激活 ppolicy 模块。 OS Version : Debian 8.4 LDAP Version: @(#) $OpenLDAP: slapd (J
实际上基于http://www.openldap.org/doc/admin24/slapdconf2.html说我可以将 slapd.conf 转换为 cn=config 格式。 为此,我尝试在服务
我有一台运行 OpenLDAP 2.4 的 Linux 服务器,它使用 cn=config 设置而不是 slapd.conf 文件。服务器当前不支持 LDAPv2 连接,仅支持 v3,所以我尝试将 o
首先我将简要解释我的架构 Openldap 服务器:安装了 openldap 的 Ubuntu 14.04 计算机。我关注了这篇文章 https://www.digitalocean.com/comm
我在 openldap 2.4.35 上使用 berkeleydb 5.0.32.NC 从源 tarball 安装了 CentSO 6.4 x86_64 。 运行几天后,ldap 服务器意外关闭。这是
我从SourceForge下载了Windows的OpenLDAP(2.4.43 x86),安装程序要求输入序列号: 据我所知,没有这样的东西吗? 我尝试输入任何内容,但是下一个按钮将不允许我继续前进
我正在使用openldap 1.2.2和php 5.5,这是我得到的错误。我对这些事情并不熟悉,我正在关注tutorial。 Error trying to get a non-existent va
我尝试向 ldap 添加新条目,但我不知道为什么它不起作用。 我有 addPeople.ldif 文件: dn: ou=People,dc=example,dc=com,dc=au ou: peopl
我正在考虑使用 OpenLDAP 在首次登录时添加密码到期和强制更改密码。 似乎使用 ppolicy 覆盖来实现这一点。 当我在 ppolicy.schema 中看到这个时,我开始使用 ppolicy
首先,我几乎是这个领域的初学者。 我应该为我们在公司内部使用的多个网站(使用共享的 openLDAP 用户和密码数据)找到一个真正的单点登录解决方案。意思是:您登录一次并连接到所有假定的站点,而不必一
我有一个 LDAP 服务器,它管理来自多个应用程序(Web 和桌面)的唯一访问点的用户。现在我需要在 OU(组织单位)中导入超过 200k 的条目,并且这个数字甚至增长。我的问题是:有关于 ldap
我尝试使用 OpenLDAP 2.4.31 和标准架构创建电话簿。 插入包含哈希 (#) 或星号 (*) 的数字将不起作用,并会返回语法错误。 RFC 告诉我数字如下:可打印字符串(字母、数字、'、(
我有一个 LDAP 服务器,它管理来自多个应用程序(Web 和桌面)的唯一访问点的用户。现在我需要在 OU(组织单位)中导入超过 200k 的条目,并且这个数字甚至增长。我的问题是:有关于 ldap
我正在编写一个 OpenLdap Controller ,其中有很多 ldap 函数。其中一个功能是获取一个 LdapUser 及其不同的属性。 例如: NamingEnumeration e
我正在尝试使用 OpenLDAP 密码策略进行身份验证。 我已使用以下内容设置我的策略: dn: cn=passwordDefault,ou=Policies,dc=company,dc=com ob
我在一台服务器上安装了 OpenLDAP,其中有 2 个独立的网卡连接到 LDAP 服务器。如果我拔下 nic1 电缆,我无法让 LDAP 通过 nic2 进行身份验证。有没有办法让 nic2 使用
我目前正在通过命令行执行 openldap。我添加了用户 John 并添加了组 devgroup,并将 John 分配到 devgroup 组。当我通过命令行删除用户(John) ldapdelete
在以下情况下我需要指导 -我正在将 RHDS 迁移到 openLDAP。我设法转换了 DIT 及其属性和模式。但是,我停留在访问控制。 在RHDS中,目前,访问控制如下- dn: dc=example
我是一名优秀的程序员,十分优秀!