gpt4 book ai didi

c# - 更改密码对 Asp.Net Core 2 的 Novell LDAP 修改不生效

转载 作者:行者123 更新时间:2023-12-05 05:18:04 27 4
gpt4 key购买 nike

对于任何可以提供帮助的人 - 我的代码在 Asp/Net Core 2.0 中运行良好,可以使用 Novell.Directory.Ldap.NETStandard (2.3.8) 添加条目到 LDAP 库。我还更新了属性,一切都没有错误。但是,当我更新密码时,它不需要。我无法使用刚刚通过代码设置的相同密码登录。我想知道是否有人遇到过这个问题,我是否需要以特殊方式对其进行编码和/或执行任何其他步骤?

这是我的代码的样子 - 非常简单,而且不会导致错误:

modList.Add(new LdapModification(LdapModification.REPLACE, new LdapAttribute("pwdLastSet", "-1")));

modList.Add(new LdapModification(LdapModification.REPLACE, new LdapAttribute("userPassword", newPassword)));

LdapModification[] mods = new LdapModification[modList.Count];

mods = (LdapModification[])modList.ToArray(typeof(LdapModification));

string dn = String.Format("CN={0},CN={1},DC=WPD,DC=Local", displayName, "Users");

_conn.Modify(dn, mods);

谢谢!克雷格

最佳答案

我没有使用“userPassword”属性,而是使用了“unicodePwd”属性并更改了编码,并且成功了。最重要的事情是用双引号将密码括起来。

string password = "\"myNewStrongPassword\"";
var encodedBytes = SupportClass.ToSByteArray(Encoding.Unicode.GetBytes(password));
var attributePassword = new LdapAttribute("unicodePwd", encodedBytes);
ldapConnection.Modify(YOUR_DISTINGUISHED_NAME, new LdapModification(LdapModification.REPLACE, attributePassword));

关于c# - 更改密码对 Asp.Net Core 2 的 Novell LDAP 修改不生效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48285865/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com