用ldapsearch验证LDAP认证信息

企业里面各种各样的系统,堆积多了以后帐号数不胜数,比较好的解决方案之一是用LDAP。不过Microsoft的ActiveDirectory认证是否成功需要有命令来进行验证,可以通过ldapsearch命令。

首先在Ubuntu上安装:

 

apt-get install ldap_utils


然后该命令就可以运行了。看个例子:

 

 

root@gitlab:~# ldapsearch -p 389 -h $ldapHost -D "CN=$firstName $lastName,OU=China,OU=International,OU=Offices,DC=esri,DC=com" -w "$pwd" -b "DC=esri,DC=com" -x "sAMAccountName=$loginName"

 

 

这里几个参数解释一下,详细参考文档:  http://linux.die.net/man/1/ldapsearch

-p 端口号

-h LDAP server的域名

-D binddn, 这个需要从LDAP管理员那里获得, 并且注意CN=$firstName $lastName 是你在Active Directory上的用户名称,first name和last name

  binddn Use the Distinguished Name  binddn to bind to the LDAP directory. For SASL binds, the server is expected to ignore this value. -w 后面跟password,要用""括起来

 

-b search base,也要从LDAP管理员那里获取

 

Use  searchbase as the starting point for the search instead of the default.

 

-x 后面接用户名,sAMAccountName不能修改

Use simple authentication instead of SASL.

 

执行后如果获得信息,那么说明配置正确,可以将配置复制到需要连接LDAP的系统服务中。

posted @   jlins  阅读(696)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)
点击右上角即可分享
微信分享提示