Merge pull request '🌚防止pwdLastSet为null时报错' (#197) from KaneLeung/Admin.NET.Pro:main into main

Reviewed-on: http://101.43.53.74:3000/Admin.NET/Admin.NET.Pro/pulls/197
This commit is contained in:
zuohuaijun 2024-12-13 21:56:49 +08:00
commit 765b4f55ef
3 changed files with 11 additions and 11 deletions

View File

@ -36,7 +36,7 @@ public class SysLdap : EntityTenant
/// <summary> /// <summary>
/// 绑定DN(有管理权限制的用户) /// 绑定DN(有管理权限制的用户)
/// </summary> /// </summary>
[SugarColumn(ColumnDescription = "绑定DN", Length = 32)] [SugarColumn(ColumnDescription = "绑定DN", Length = 128)]
[Required] [Required]
public virtual string BindDn { get; set; } public virtual string BindDn { get; set; }

View File

@ -266,15 +266,15 @@ public class SysLdapService : IDynamicApiController, ITransient
{ {
var userLdap = new SysUserLdap var userLdap = new SysUserLdap
{ {
Account = !attrs.ContainsKey(bindAttrAccount) ? null : attrs.GetAttribute(bindAttrAccount)?.StringValue, Account = attrs.ContainsKey(bindAttrAccount) ? attrs.GetAttribute(bindAttrAccount)?.StringValue : null,
EmployeeId = !attrs.ContainsKey(bindAttrEmployeeId) ? null : attrs.GetAttribute(bindAttrEmployeeId)?.StringValue, EmployeeId = attrs.ContainsKey(bindAttrEmployeeId) ? attrs.GetAttribute(bindAttrEmployeeId)?.StringValue : null,
DeptCode = deptCode, DeptCode = deptCode,
UserName = !attrs.ContainsKey("name") ? null : attrs.GetAttribute("name")?.StringValue, UserName = attrs.ContainsKey("name") ? attrs.GetAttribute("name")?.StringValue : null,
Mail = !attrs.ContainsKey("mail") ? null : attrs.GetAttribute("mail")?.StringValue Mail = attrs.ContainsKey("mail") ? attrs.GetAttribute("mail")?.StringValue : null
}; };
var pwdLastSet = !attrs.ContainsKey("pwdLastSet") ? null : attrs.GetAttribute("pwdLastSet")?.StringValue; var pwdLastSet = attrs.ContainsKey("pwdLastSet") ? attrs.GetAttribute("pwdLastSet")?.StringValue : null;
if (!pwdLastSet!.Equals("0")) userLdap.PwdLastSetTime = DateTime.FromFileTime(Convert.ToInt64(pwdLastSet)); if (pwdLastSet != null && !pwdLastSet.Equals("0")) userLdap.PwdLastSetTime = DateTime.FromFileTime(Convert.ToInt64(pwdLastSet));
var userAccountControl = !attrs.ContainsKey("userAccountControl") ? null : attrs.GetAttribute("userAccountControl")?.StringValue; var userAccountControl = attrs.ContainsKey("userAccountControl") ? attrs.GetAttribute("userAccountControl")?.StringValue : null;
if ((Convert.ToInt32(userAccountControl) & 0x2) == 0x2) // 检查账户是否已过期通过检查userAccountControl属性的特定位 if ((Convert.ToInt32(userAccountControl) & 0x2) == 0x2) // 检查账户是否已过期通过检查userAccountControl属性的特定位
userLdap.AccountExpiresFlag = true; userLdap.AccountExpiresFlag = true;
if ((Convert.ToInt32(userAccountControl) & 0x10000) == 0x10000) // 检查账户密码设置是否永不过期 if ((Convert.ToInt32(userAccountControl) & 0x10000) == 0x10000) // 检查账户密码设置是否永不过期
@ -428,9 +428,9 @@ public class SysLdapService : IDynamicApiController, ITransient
{ {
Pid = org.Id, Pid = org.Id,
Id = YitIdHelper.NextId(), Id = YitIdHelper.NextId(),
Code = !attrs.ContainsKey(sysLdap.BindAttrCode) ? null : new Guid(attrs.GetAttribute(sysLdap.BindAttrCode)?.ByteValue).ToString(), Code = attrs.ContainsKey(sysLdap.BindAttrCode) ? new Guid(attrs.GetAttribute(sysLdap.BindAttrCode)?.ByteValue).ToString() : null,
Level = org.Level + 1, Level = org.Level + 1,
Name = !attrs.ContainsKey(sysLdap.BindAttrAccount) ? null : attrs.GetAttribute(sysLdap.BindAttrAccount)?.StringValue, Name = attrs.ContainsKey(sysLdap.BindAttrAccount) ? attrs.GetAttribute(sysLdap.BindAttrAccount)?.StringValue : null,
OrderNo = listOrgs.Count + 1, OrderNo = listOrgs.Count + 1,
}; };
} }

View File

@ -34,7 +34,7 @@
</el-col> </el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20"> <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
<el-form-item label="绑定DN" prop="bindDn"> <el-form-item label="绑定DN" prop="bindDn">
<el-input v-model="formData.bindDn" placeholder="请输入绑定DN" maxlength="32" show-word-limit clearable /> <el-input v-model="formData.bindDn" placeholder="请输入绑定DN" maxlength="128" show-word-limit clearable />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20"> <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">