如何使用LdapConnection 类 (1)链接 Ldap服务器
- 格式:doc
- 大小:27.00 KB
- 文档页数:2
服务器版本:Windows server 2012一、搭建域控服务器1、配置网络,由于本机会搭建DNS服务器,因此首选DNS服务器设置为127.0.0.12、打开服务器管理器3、点击添加角色和功能,下一步4、选基于角色或基于功能的安装,下一步5、选择要安装角色或功能的服务器,服务器池中只有本机,下一步6、选择要安装的角色,选中Active Directory 域服务,添加功能7、选择角色对应的功能,默认即可,下一步8、AD概览信息,目前还没有安装DNS服务器,后续会安装,下一步9、确认信息,安装10、开始安装AD,后续会需要配置AD11、单击叹号小旗,将此服务器提升为域控制器12、开始配置AD域服务器,选择添加新林,并定义根域名,尽量想好,定义后修改比较麻烦,下一步13、默认即可,输入目录还原模式密码14、无法委派DNS服务器提示,不用管他,因为我们还没有创建DNS服务器,之后系统会自己创建DNS服务器15、netBIOS域名,默认即可,下一步16、AD数据库及日志文件存储位置,默认即可,下一步17、检查配置选项,一般没有问题,下一步即可18、点击查看脚本,可以看到Windows PowerShell配置AD的参数,会看到自动安装DNS服务器19、检查此计算机是否满足安装AD 域服务器的条件,满足可点击安装20、安装过程21、安装完成,需要重启计算机22、登陆该计算机,注意需要以域名的方式登录(zl\)23、安装AD 域服务和DNS服务器之后打开服务器管理器24、AD 用户和计算机管理界面25、使用LdapAdmin.exe测试是否可以通过LdAP方式连接Ad,连接成功,但是此时还不够使用ldaps(SSL.TLS)方式连接AD,需要安装IIS服务器和CA证书服务器/uid-29178012-id-3963202.html二、安装IIS服务器和CA证书服务器安装过程与上面差不多,一步步完成后进行配置一下。
Oracle LDAP 设置指南一.概述本指南用于说明如何使用LDAP 服务器保存邮件系统用户信息。
邮件服务器用户验证结构如下:验证服务器用于跨数据库,LDAP服务器的验证中心。
邮件服务器把验证请求发送到验证服务器,验证服务器再根据具体的后台用户信息保存类型进行相应的用户信息读取,验证。
二.LDAP 服务器设置本指南以OpenLDAP 做为例子LDAP 服务器。
配置步骤如下:1)把以下schema 文件(turbomail.schema)加入openldap/etc/schema.attributetype ( 5.1.1.1 NAME 'domain'DESC 'domain name'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{128} )attributetype ( 5.1.1.2 NAME 'enable'DESC 'enable'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{5} )attributetype ( 5.1.1.3 NAME 'enablesmtp'DESC 'enable_smtp'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{5} )attributetype ( 5.1.1.4 NAME 'enableimap4'DESC 'enable_imap4'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{5} )attributetype ( 5.1.1.5 NAME 'enablepop3' DESC 'enable_pop3'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{5} )attributetype ( 5.1.1.6 NAME 'enablewebaccess' DESC 'enable_webaccess'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{5} )attributetype ( 5.1.1.7 NAME 'enablelocaldomain' DESC 'enable_webaccess'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{5} )attributetype ( 5.1.1.8 NAME 'enablesms'DESC 'enable_sms'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{5} )attributetype ( 5.1.1.9 NAME 'maxmailboxsize' DESC 'max_mailbox_size'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{64} )attributetype ( 5.1.1.10 NAME 'maxmailboxmsgs' DESC 'max_mailbox_msgs'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{64} )attributetype ( 5.1.1.11 NAME 'usertype'DESC 'usertype'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{5} )attributetype ( 5.1.1.12 NAME 'tpassword'DESC 'tpassword'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{128} )attributetype ( 5.1.1.13 NAME 'modifytime' DESC 'modifytime'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{128} )attributetype ( 5.1.1.14 NAME 'firstname'DESC 'firstname'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{128} )attributetype ( 5.1.1.15 NAME 'organization' DESC 'organiztion'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{128} )attributetype ( 5.1.1.16 NAME 'department' DESC 'department'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{128} )attributetype ( 5.1.1.17 NAME 'address'DESC 'address'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{128} )attributetype ( 5.1.1.18 NAME 'city'DESC 'city'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{128} )attributetype ( 5.1.1.19 NAME 'tpostalcode' DESC 'tpostalcode'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{128} )attributetype ( 5.1.1.20 NAME 'telephone'DESC 'telephone'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{128} )attributetype ( 5.1.1.21 NAME 'stateprovince' DESC 'stateprovince'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{128} )attributetype ( 5.1.1.22 NAME 'country'DESC 'country'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{128} )attributetype ( 5.1.1.23 NAME 'items'DESC 'items'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{64} )attributetype ( 5.1.1.24 NAME 'mobile'DESC 'mobile'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{128} )attributetype ( 5.1.1.25 NAME 'realname'DESC 'realname'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{128} )attributetype ( 5.1.1.26 NAME 'receivecond' DESC 'receivecond'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{128} )attributetype ( 5.1.1.27 NAME 'remaincopy' DESC 'remaincopy'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{128} )attributetype ( 5.1.1.28 NAME 'replacercpt'DESC 'replacercpt'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{64} )attributetype ( 5.1.1.29 NAME 'users'DESC 'users'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{2046} )attributetype ( 5.1.1.30 NAME 'helodomain'DESC 'helodomain'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{128} )attributetype ( 5.1.1.31 NAME 'bdefault'DESC 'bdefault'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{6} )attributetype ( 5.1.1.32 NAME 'enablereg'DESC 'enablereg'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{6} )attributetype ( 5.1.1.33 NAME 'domainusers' DESC 'domainusers'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{64} )attributetype ( 5.1.1.34 NAME 'license'DESC 'license'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{128} )attributetype ( 5.1.1.35 NAME 'totalmailboxsize' DESC 'totalmailboxsize'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{64} )attributetype ( 5.1.1.36 NAME 'notetime'DESC 'notetime'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{64} )attributetype ( 5.1.1.37 NAME 'state'DESC 'state'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{64} )attributetype ( 5.1.1.38 NAME 'notesetdisable' DESC 'notesetdisable'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{5} )attributetype ( 5.1.1.39 NAME 'lastname'DESC 'lastname'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{128} )attributetype ( 5.1.1.40 NAME 'noteaddress' DESC 'noteaddress'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{128} )attributetype ( 5.1.1.41 NAME 'username'DESC 'username'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{128} )attributetype ( 5.1.1.42 NAME 'smsenablesms' DESC 'enable_sms'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{5} )attributetype ( 5.1.1.43 NAME 'needapprove' DESC 'needapprove'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{5} )attributetype ( 5.1.1.44 NAME 'jointype'DESC 'jointype'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{64} )attributetype ( 5.1.1.45 NAME 'visibletype' DESC 'visibletype'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{64} )attributetype ( 5.1.1.46 NAME 'subscribe'DESC 'subscribe'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{64} )attributetype ( 5.1.1.47 NAME 'unsubscribe' DESC 'unsubscribe'EQUALITY caseIgnoreMatchSUBSTR caseIgnoreSubstringsMatchSYNTAX 1.3.6.1.4.1.1466.115.121.1.15{64} )objectclass ( 5.1.1.99 NAME 'mailuser'DESC 'mailuser'SUP top STRUCTURALMUST ( username )MAY ( domain $ enable $ enablesmtp $ enableimap4 $enablepop3 $ enablewebaccess $ enablelocaldomain $ enablesms $maxmailboxsize $ maxmailboxmsgs $ usertype $ tpassword $modifytime $ firstname $ lastname $ organization $ department $ address $city $ tpostalcode $ telephone $ stateprovince $ country $ items $ mobile $realname $ receivecond $ remaincopy $ replacercpt $ users $ needapprove $ jointype $ visibletype $ subscribe $ unsubscribe) )objectclass ( 5.1.1.98 NAME 'maildomain'DESC 'maildomain'SUP top STRUCTURALMUST ( domain )MAY( helodomain $ bdefault $ enablereg $ domainusers $ license $ enable $ enablesmtp $ enableimap4 $enablepop3 $ enablewebaccess $ enablelocaldomain $ enablesms $maxmailboxsize $ maxmailboxmsgs $ totalmailboxsize $ notetime $noteaddress $ state $ notesetdisable $ modifytime $ smsenable) )2)配置ldapd.conf,加入以下指定turbomail.schema 的配置。
LDAP服务器的配置通过如下命令*:\IBM\WebSphere\wp_profile\PortalServer\wizard\configwizard.bat,(AIX下命令:*:\IBM\WebSphere\wp_profile\PortalServer\wizard\./configwizard.sh)进入配置安全性(可视化配置,关闭server1和WebSphere_Portal两个server)O=sxnx,(“0”表示组织和你domino中组织名对应)利用命令行配置ldap修改配置文件,标准配置文件标准配置说明文件标准配置标准文件IBM\WebSphere\wp_profile\ConfigEngine\目录下执行以下命令执行命令任务之前,请先确认此时PORTAL和W AS服务器处于停止状态。
\IBM\WebSphere\wp_profile\bin>serverStatus.bat –all 查看当前服务器状态命令:1ConfigEngine.bat validate-standalone-ldap -DWasPassword=passw0rd(AIX下./ConfigEngine.sh validate-standalone-ldap -DWasPassword=passw0rd)错误信息1:action-validate-ldap-connection:Thu Jan 14 15:40:29 CST 2010[ldapcheck]############################################################### [ldapcheck] ldapURL : 9.1.7.13:389[ldapcheck] ldapUser : cn=wpbind,o=sxnx[ldapcheck] ldapPassword : ******************[ldapcheck] ldapSslEnabled : false[ldapcheck] javax.naming.AuthenticationException: [LDAP: error code 49 - Failed,invalid credentials for cn=wpbind,o=sxnx][ldapcheck] ERROR: 4[ldapcheck] Invalid or insufficient authorization privileges.BUILD FAILED解决:可能配置文件中没有修该完全。
ldaputils使用方法LDAP (Lightweight Directory Access Protocol) 是一种用于访问和维护分布式目录信息服务的开放标准协议。
在实际应用中,我们经常需要使用LDAP来进行用户身份验证、访问控制和其他目录服务操作。
为了简化LDAP的使用,ldaputils是一个非常有用的工具,它提供了一些方便的方法来执行LDAP操作。
首先,要使用ldaputils,你需要安装它。
你可以通过pip来安装ldaputils:bash.pip install ldaputils.一旦安装完成,你就可以开始使用ldaputils来执行LDAP操作了。
下面是一些ldaputils的使用方法:1. 连接LDAP服务器。
python.from ldaputils import LDAPClient.# 创建LDAPClient对象并连接到LDAP服务器。
ldap_client = LDAPClient("ldap://your_ldap_server", "username", "password")。
2. 搜索LDAP目录。
python.# 搜索LDAP目录。
result =ldap_client.search("ou=users,dc=example,dc=com","(cn=johndoe)")。
print(result)。
3. 添加新条目。
python.# 添加新条目。
entry = {。
"cn": "johndoe",。
"sn": "Doe",。
"mail":"*******************",。
"objectClass": ["inetOrgPerson"]}。
ldapadmin使用手册一、简介ldapadmin是一款功能强大的LDAP(轻量目录访问协议)管理工具,它提供了用户友好的界面,用于管理和维护LDAP服务器上的目录。
本手册将向您介绍如何使用ldapadmin进行LDAP目录的管理。
二、安装和配置2.1 下载和安装ldapadmin1.打开ldapadmin的官方网站。
2.在下载页面选择适用于您操作系统的版本,然后单击下载按钮。
3.下载完成后,按照安装向导进行安装。
2.2 配置ldap服务器连接在首次启动ldapadmin之后,您需要配置与LDAP服务器的连接。
按照以下步骤进行配置: 1. 打开ldapadmin并选择“文件”>“设置”。
2. 在设置窗口中,选择“连接”选项卡。
3. 点击“添加”按钮,输入连接名称和LDAP服务器的主机名和端口号。
4. 输入管理员用户名和密码,并验证连接是否成功。
5. 单击“确定”保存配置。
三、目录管理3.1 创建目录项您可以使用ldapadmin创建新的目录项。
按照以下步骤进行操作: 1. 在ldapadmin的主界面上选择您要在其中创建目录项的上级目录。
2. 单击工具栏上的“新建目录项”按钮。
3. 在弹出的对话框中,输入新目录项的属性和值。
4. 单击“确定”按钮创建目录项。
3.2 编辑目录项您可以通过ldapadmin编辑目录项的属性和值。
按照以下步骤进行操作: 1. 在ldapadmin的主界面上选择要编辑的目录项。
2. 单击工具栏上的“编辑目录项”按钮。
3. 在弹出的对话框中,可以修改目录项的属性和值。
4. 单击“确定”按钮保存更改。
3.3 删除目录项如果您需要删除一个目录项,可以按照以下步骤进行操作: 1. 在ldapadmin的主界面上选择要删除的目录项。
2. 单击工具栏上的“删除目录项”按钮。
3. 单击“确定”按钮确认删除操作。
四、搜索和过滤4.1 执行搜索操作ldapadmin提供了强大的搜索功能,您可以根据特定的条件搜索目录项。
ldap认证流程LDAP认证流程全称是“轻量目录访问协议”(LightweightDirectoryAccessProtocol,LDAP)认证流程。
它是一种基于客户端/服务器的、基于 TCP/IP应用协议,通过使用安全的认证机制来访问、管理和搜索分布式目录服务器上存储的信息。
LDAP认证流程一般包括以下5步:第一步:客户端连接LDAP服务器。
客户端连接LDAP服务器时,首先会向服务器发送连接请求,然后服务器会接受该请求并启动安全会话。
第二步:客户端发送身份验证请求。
客户端必须发送一个身份验证请求给LDAP服务器,提供一个认证的名字,一般是用户名。
第三步:服务器处理身份验证请求。
LDAP服务器会根据客户端发送的用户名,查找到该用户名所关联的密码,再和客户端发送的密码进行比对,如果两者相同,则LDAP服务器会认可客户端的请求。
第四步:身份验证成功,服务器返回绑定信息。
如果客户端的身份验证请求被LDAP服务器认可,那么LDAP服务器就会发送一个绑定信息给客户端,以表示客户端已经被认可为该LDAP服务器的合法用户。
第五步:客户端获取服务器上的信息。
当客户端获取到所需要的绑定信息之后,就可以向LDAP服务器发送请求,请求获取服务器上存放的信息了。
LDAP服务器接收到客户端的请求之后,就会根据客户端的要求返回所需要的信息。
LDAP认证流程一般用于某些网络资源的认证和授权,例如某些安全性比较高的服务器上的文件共享等,通常会使用LDAP进行认证和授权操作。
传统上,LDAP认证流程是运行在企业网络内部的,只有本地用户可以访问资源,但是随着网络的发展,现在企业的外部用户也可以使用LDAP认证流程进行认证和授权。
LDAP认证流程具有很多优势,例如,可以实现网络信息搜索,提供两步认证,具有安全性等。
此外,LDAP还支持其他认证系统,比如Kerberos认证系统,可以同时使用两套认证机制,以更好地保护服务器上存储的信息。
连接不同LDAP(OpenLDAP,SunOne,AD,Domino)OpenLDAPJXplorer连接:密码为:password12345代码连接:public class TestSunOneConnection {public static void main(String[] args) {String adminName = "cn=Manager,dc=chinautrust,dc=com";String adminPassword = "password12345";String ldapURL = "ldap://localhost:389";String authenSchema= "simple";LDAPConnection conn=newLDAPConnection(ldapURL,adminName,adminPassword,authenSchema); try {// Create the initial directory contextLdapContext ctx = conn.getLdapContext();// Create the search controlsSearchControls searchCtls = new SearchControls();// Specify the search scopesearchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);// specify the LDAP search filterString searchFilter = "(objectclass=person)";// Specify the Base for the searchString searchBase = "ou=person,ou=utrust,dc=chinautrust,dc=com";// Specify the attributes to returnString returnedAtts[] = { "memberOf" };searchCtls.setReturningAttributes(returnedAtts);// Search for objects using the filterNamingEnumeration answer = ctx.search(searchBase, searchFilter, searchCtls); // Loop through the search resultswhile (answer.hasMoreElements()) {SearchResult sr = (SearchResult) answer.next();System.out.println(">>>" + sr.getName());}ctx.close();}catch (NamingException e) {System.err.println("Problem searching directory: " + e);}}}SunOneJXplorer连接:密码为:password12345代码连接:public class TestSunOneConnection {public static void main(String[] args) {String adminName = "cn=Directory Manager";String adminPassword = "password12345";String ldapURL = "ldap://192.168.0.111:389";String authenSchema= "simple";LDAPConnection conn=newLDAPConnection(ldapURL,adminName,adminPassword,authenSchema);try {// Create the initial directory contextLdapContext ctx = conn.getLdapContext();// Create the search controlsSearchControls searchCtls = new SearchControls();// Specify the search scopesearchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);// specify the LDAP search filterString searchFilter = "(objectclass=person)";// Specify the Base for the searchString searchBase = "ou=person,ou=utrust,dc=chinautrust,dc=com";// Specify the attributes to returnString returnedAtts[] = { "memberOf" };searchCtls.setReturningAttributes(returnedAtts);// Search for objects using the filterNamingEnumeration answer = ctx.search(searchBase, searchFilter, searchCtls); // Loop through the search resultswhile (answer.hasMoreElements()) {SearchResult sr = (SearchResult) answer.next();System.out.println(">>>" + sr.getName());}ctx.close();}catch (NamingException e) {System.err.println("Problem searching directory: " + e);}}}ADJXplorer连接:密码为:123456代码连接:public class TestADConnection {public static void main(String[] args) {String adminName = "CN=Administrator,CN=Users,DC=all,DC=com"; String adminPassword = "123456"; String ldapURL = "ldap://192.168.0.190:389";String authenSchema= "simple";LDAPConnection conn=newLDAPConnection(ldapURL,adminName,adminPassword,authenSchema);try {// Create the initial directory contextLdapContext ctx = conn.getLdapContext();// Create the search controlsSearchControls searchCtls = new SearchControls();// Specify the search scopesearchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);// specify the LDAP search filterString searchFilter = "(|(objectclass=user)(objectclass=person))";// Specify the Base for the searchString searchBase = "CN=Users,DC=all,DC=com";// Specify the attributes to returnString returnedAtts[] = { "memberOf" };searchCtls.setReturningAttributes(returnedAtts);// Search for objects using the filterNamingEnumeration answer = ctx.search(searchBase, searchFilter, searchCtls);// Loop through the search resultswhile (answer.hasMoreElements()) {SearchResult sr = (SearchResult) answer.next();System.out.println(">>>" + sr.getName());}ctx.close();}catch (NamingException e) {System.err.println("Problem searching directory: " + e);}}}DominoJXplorer连接:密码为:oa123代码连接:public class TestDominoLDAPConnection {public void search() {String adminName = "CN=admin,O=Domain";String adminPassword = "oa123";String ldapURL = "ldap://192.168.0.201:389";String authenSchema= "simple";LDAPConnection conn=newLDAPConnection(ldapURL,adminName,adminPassword,authenSchema); try { // Create the initial directory contextLdapContext ctx = conn.getLdapContext();// Create the search controlsSearchControls searchCtls = new SearchControls();// Specify the search scopesearchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);// specify the LDAP search filterString searchFilter = "(objectClass=person)";// Specify the Base for the searchString searchBase = "";// Specify the attributes to returnString returnedAtts[] = { "memberOf" };searchCtls.setReturningAttributes(returnedAtts);// Search for objects using the filterNamingEnumeration answer = ctx.search(searchBase, searchFilter, searchCtls);// Loop through the search resultswhile (answer.hasMoreElements()) {SearchResult sr = (SearchResult) answer.next();System.out.println(">>>" + sr.getName());}ctx.close();}catch (NamingException e) {System.err.println("Problem searching directory: " + e);}}public void add() {}public static void main(String[] args) {TestDominoLDAPConnection con = new TestDominoLDAPConnection();con.search();}}总结以上都是使⽤超级管理进⾏连接的,使⽤普通⽤户的账号密码也可以连接各种LDAP。
ldap 协议LDAP(Lightweight Directory Access Protocol)是一种用于访问和维护分布式目录信息服务的应用级协议。
它通常用于在网络中的目录服务中进行身份验证和授权。
LDAP协议基于X.500标准,但是比X.500更简单,因此被称为轻量级。
LDAP协议的基本概念是将目录作为一个树形结构的数据库,其中包含了各种对象的信息。
LDAP服务器使用这个树形结构来存储和组织数据,而LDAP客户端则可以使用LDAP协议来查询、添加、修改和删除这些数据。
LDAP协议的核心是基于客户端-服务器模型的通信。
客户端向服务器发送LDAP请求,服务器则返回相应的LDAP响应。
LDAP协议使用TCP和UDP作为传输协议,通常使用389端口进行通信。
在LDAP中,数据以条目(entry)的形式存储。
每个条目都有一个唯一的标识符(DN),用来在整个目录树中唯一标识这个条目。
条目包含了一个或多个属性-值对,用来描述这个条目所代表的对象的属性信息。
例如,一个用户条目可以包含属性如姓名、电子邮件地址、电话号码等。
LDAP协议定义了一系列的操作,用来对目录中的数据进行增删改查。
常见的操作包括,绑定(bind)、搜索(search)、添加(add)、删除(delete)、修改(modify)等。
通过这些操作,LDAP客户端可以与LDAP服务器进行交互,从而实现对目录数据的管理和访问。
除了基本的操作外,LDAP协议还提供了一些扩展功能,如安全认证、访问控制、数据复制等。
这些功能使得LDAP协议成为了企业网络中常用的身份认证和授权解决方案。
总的来说,LDAP协议是一种灵活、高效的目录访问协议,它为网络中的目录服务提供了统一的访问接口,为用户和应用程序提供了方便的身份认证和授权机制。
在企业网络中,LDAP协议被广泛应用于各种系统和应用中,如邮件服务、文件共享、VPN接入等。
通过LDAP协议,用户可以方便地访问和管理企业网络中的各种资源,从而提高了网络管理的效率和安全性。
python-ldap 用法如何使用pythonldapPython是一种功能强大且广泛使用的编程语言,在许多领域都有着广泛的应用,其中包括与LDAP(轻量级目录访问协议)服务器交互。
LDAP 是一种协议,用于在网络上访问和维护目录信息。
Pythonldap是一个用于与LDAP服务器进行通信的Python模块,它提供了一种简便的方式来连接、查询和维护LDAP服务器中的目录信息。
本文将一步一步地介绍如何使用pythonldap模块。
第一步:安装pythonldap模块要使用pythonldap模块,首先需要安装它。
可以通过使用pip来安装pythonldap模块。
打开终端(对于Windows用户,是命令提示符)并输入以下命令:pip install python-ldap这将会从Python Package Index(PyPI)下载并安装pythonldap模块。
请注意,安装pythonldap模块时可能会遇到一些依赖关系问题,这需要根据您的操作系统进行解决。
通常情况下,pip会自动解决依赖关系并安装必需的软件包。
第二步:导入pythonldap模块安装完pythonldap模块后,就可以在Python脚本中导入它。
在您的Python脚本的顶部添加以下代码:pythonimport ldap这将会导入pythonldap模块,使您能够使用其中的功能。
第三步:建立与LDAP服务器的连接在与LDAP服务器进行交互之前,需要建立一个连接。
使用pythonldap 模块的`ldap.initialize()`函数来建立连接。
以下是一个示例代码:pythonldap_server = 'ldap:myldapserver' # 替换成您的LDAP服务器地址conn = ldap.initialize(ldap_server)这将会建立与指定LDAP服务器的连接。
请确保将`ldap_server`变量替换为您实际的LDAP服务器地址。
如何使用LdapConnection 类(1)链接 Ldap服务器
C#提供了 LdapConnection 类用于连接Microsoft Active Directory 域服务或 LDAP 服务器的 TCP/IP 或 UDP LDAP 连接。
下面是连接 Ldap的连接方法和大家分享下:
static LdapConnection ldapConnection;
static string ldapServer;
static NetworkCredential credential;
static string targetOU;
static string pwd;
public void LdapBind()
{
ldapServer = "172.18.69.204:389";
targetOU = "cn=Manager,dc=tst,dc=com";
pwd = "000000";
//credential = new NetworkCredential(String.Empty, String .Empty);
credential = new NetworkCredential(targetOU, pwd);
string dn = "";
//ldapConnection = new LdapConnection(new LdapDirectoryId entifier(ldapServer));
//ldapConnection.SessionOptions.ProtocolVersion = 3;//Lda p协议版本
//ldapConnection.AuthType = AuthType.Anonymous;//不传递密码进行连接
ldapConnection = new LdapConnection(ldapServer);
ldapConnection.AuthType = AuthType.Basic;
ldapConnection.Credential = credential;
try { Console.WriteLine("链接."); ldapConnection.Bind(); Console.W riteLine("链接成功
"); } catch (Exception ee) {
Console.WriteLine(ee.Message); } ldapConnection. Dispose();
}
注意
1、如果我们使用ldapConnection.AuthType = AuthType.Anonymous; 的认证方式,就一定要让Dn与Pwd为空,实现匿名认证方式,如:
credential = new NetworkCredential(String.Empty, String.Empty);
2、使用c#连接Ldap服务器,还可以使用 Novell公司的Novell.Directory.Ldap 来实现。