当前位置: 首页 > news >正文

企业网站是什么wordpress主题打开慢

企业网站是什么,wordpress主题打开慢,微商城开发,链天网站建设在前面的两篇文章中#xff0c;我详细的介绍了使用ldap与window AD服务集成#xff0c;实现ToB项目中的身份认证集成方案#xff0c;包括技术方案介绍、环境配置#xff1a; ToB项目身份认证AD集成#xff08;一#xff09;#xff1a;基于目录的用户管理、LDAP和Active…在前面的两篇文章中我详细的介绍了使用ldap与window AD服务集成实现ToB项目中的身份认证集成方案包括技术方案介绍、环境配置 ToB项目身份认证AD集成一基于目录的用户管理、LDAP和Active Directory简述 ToB项目身份认证AD集成二一分钟搞定window server 2003部署AD域服务并支持ssl加密多图保姆教程证书脚本 在本文中我将详细介绍如何利用 ldapjs 库使之一个 Node.js 服务类 LdapService该类实现了与 之前搭建的Windows AD 交互包括用户搜索、身份验证、密码修改等功能。 也算是AD集成系列的完结吧后续可能出其它客户端的对接但目前工作核心在AI那块儿大概率也不会继续了 一、实现方案和LdapService类概述 LdapService 类的核心是通过 LDAP轻量级目录访问协议与 AD 进行交互提供用户搜索、认证、密码修改、重置等功能。下图是该类的基本结构后续将一步步的介绍如何实现各个方法。 class LdapService {client: Promiseldap.Client;private config: MustPropertyLdapServiceConfig;constructor(config: LdapServiceConfig) {this.config {...defaultConfig,...config,};this.client this.init();}async findUsers(filter this.config.userSearchFilter,attributes: string[] [sAMAccountName, userPrincipalName, memberOf]) {}// 关闭连接async close() {(await this.client).destroy();}async findUser() {}// 修改用户密码的方法async changePassword(user: LdapUserSimInfo,newPassword: string,oldPassword: string) {}// 用户认证的方法 - 检查密码是否正确async checkPassword(user: LdapUserSimInfo, password: string) {}/*重置密码 */async resetPassword(user: LdapUserSimInfo, resetPassword: string) {}private async init() {const conf this.config;const client ldap.createClient({url: conf.url,tlsOptions: {minVersion: TLSv1.2,rejectUnauthorized: false,},});await promisify(client.bind).call(client, conf.adminDN, conf.adminPassword);return client; // 返回绑定后的客户端}private mergeSearchEntryObjectAttrs(entry: ldap.SearchEntryObject) {}private doSearch(client: ldap.Client, opts: ldap.SearchOptions) {}private encodePassword(password) {}private safeDn(dn: string) {} }二、中文字段的特殊patch ldap.js对于数据的字段进行了escape操作会导致中文输入被转化成\xxx的形式无论是接收的数据还是发送的请求这时候会导致cn包含中文会出现错。需要用如下方法进行patch通过在出现问题的rdn上配置unescaped参数控制是否对字符串进行escape如果不知道啥是escape参见十六进制转义escape介绍 const oldString ldap.RDN.prototype.toString; ldap.RDN.prototype.toString function () {return oldString.call(this, { unescaped: this.unescaped }); };加了这个补丁后就可以控制rdn的转义情况了。 三、用户搜索功能 findUsers() 方法用于在 AD 中搜索用户返回用户的基本信息。 async findUsers(filter this.config.userSearchFilter,attributes: string[] [sAMAccountName, userPrincipalName, memberOf] ): PromiseLdapUserSimInfo[] {await this.bindAsAdmin();const opts {filter, scope: sub, attributes: Array.from(new Set([distinguishedName, cn].concat(attributes))),};const searchResult await this.doSearch(await this.client, opts);return searchResult.map((user) {return this.mergeSearchEntryObjectAttrs(user) as LdapUserSimInfo;}); }filter 是用于搜索的 LDAP 过滤器默认为查找所有用户的 (objectClassuser) 过滤器。attributes 参数允许指定返回哪些用户属性默认返回 sAMAccountName、userPrincipalName 和 memberOf 等属性。该方法调用了 doSearch() 进行搜索并通过 mergeSearchEntryObjectAttrs() 整理和转换 AD 返回的用户数据。 doSearch() 方法是实际进行 LDAP 搜索的地方 private doSearch(client: ldap.Client, opts: ldap.SearchOptions) {return new Promiseldap.SearchEntryObject[]((resolve, reject) {const entries [] as ldap.SearchEntryObject[];client.search(this.config.userSearchBase, opts, (err, res) {if (err) {return reject(err);}res.on(searchEntry, (entry) {entries.push(entry.pojo);});res.on(end, (result) {if (result?.status ! 0) {return reject(new Error(Non-zero status from LDAP search: ${result?.status}));}resolve(entries);});res.on(error, (err) {reject(err);});});}); }client.search() 是 ldapjs 提供的一个方法用于执行搜索操作。搜索结果通过事件 searchEntry 逐条返回最终在 end 事件时完成。 四、用户认证功能 checkPassword() 方法用于用户身份验证检查用户输入的密码是否正确。 async checkPassword(user: LdapUserSimInfo, password: string) {const userDN user.objectName;const client await this.client;await promisify(client.bind).call(client, userDN, password); }通过 LDAP 的 bind() 方法可以尝试使用用户的 DN 和密码进行绑定。如果绑定成功表示密码正确否则会抛出错误表示认证失败。 五、密码修改功能 changePassword() 方法允许用户修改自己的密码。 async changePassword(user: LdapUserSimInfo, newPassword: string, oldPassword: string) {await this.bindAsAdmin();const userDN this.safeDn(user.objectName);const changes [new ldap.Change({operation: delete,modification: new ldap.Attribute({type: unicodePwd,values: [this.encodePassword(oldPassword)],}),}),new ldap.Change({operation: add,modification: new ldap.Attribute({type: unicodePwd,values: [this.encodePassword(newPassword)],}),}),];const client await this.client;await promisify(client.modify).call(client, userDN, changes); }在修改密码时LDAP 需要先删除旧密码再添加新密码。这里使用 ldap.Change 创建修改操作通过 client.modify() 方法应用到 AD。 六、密码重置功能 resetPassword() 方法允许管理员重置用户的密码 async resetPassword(user: LdapUserSimInfo, resetPassword: string) {await this.bindAsAdmin();const client await this.client;const userDN this.safeDn(user.objectName);const changes new ldap.Change({operation: replace,modification: new ldap.Attribute({type: unicodePwd,values: [this.encodePassword(resetPassword)],}),});await promisify(client.modify).call(client, userDN, changes); }与修改密码不同重置密码直接使用 replace 操作替换用户的现有密码。 七、结语 通过对 LdapService 类的逐步解析相信你已经学会了如何利用 ldapjs 库与 Windows AD 进行交互。在实际使用中还可以根据业务需求对这个类进行扩展从而满足大规模企业系统中的用户管理需求。 另外这个中文的问题暂时还只能是如此打补丁期待社区修复可能不会那么及时
http://www.hkea.cn/news/14379098/

相关文章:

  • 什么网站做旅行计划个人引擎网站什么做
  • 网站建设与维护好学吗投票网站怎么做
  • 代做网站的公司wordpress音乐自动播放
  • 网站建设活动计划网站页脚的信息都有什么
  • 网站做app安全吗好看的学校网站模板
  • 门户网站案例辽宁建设工程信息网登录不上去
  • 网站建设及推广图片网站开发使用哪种语言
  • 安康做网站公司湖南株洲建设局网站
  • app介绍类网站模板潍城区建设局网站
  • vs做网站教程深圳网站建设一尘互联
  • 360网站安全检测eclipse怎么做网页
  • 做网站的技术wordpress 配置要求
  • 个人网站这么做南阳那里有做网站的
  • 静态网站策划书ios开发者账号有什么用
  • 班级网站页面设计通栏网站
  • 门户网站建设探究管理咨询项目
  • 上海智能网站建设平台专业装修超市的装修公司
  • 个人网站开发与实现开题报告扬中论坛最新
  • 教你做美食的网站网络营销方式文献
  • 青岛做网站和小程序的公司metasploit wordpress
  • 做网站建设哪家公司好北京国家建设部网站首页
  • 网站推广 优帮云厨具 技术支持东莞网站建设
  • 义乌专业做网站的公司专业网站建设 公司
  • 外贸服装网站模板c 做视频网站
  • 网站项目报价做网站那家比较好
  • 网站建设岗位说明书手机软件app免费下载
  • 中国移动网站建设情况分析wordpress抽奖工具
  • 重庆网站制作一般需要多少钱查找做像册的网站
  • 网站入口英文手机网站模板
  • 建什么网站赚钱电子商务网站建设与维护期末答案