- 浏览: 772222 次
- 性别:
- 来自: 广州
文章分类
最新评论
-
corelengine:
好文,支持一下!
在 Spring Web Flow 项目中应用 Hessian 服务 -
corelengine:
感谢分享,不过你的工程太简单了,怎么可以导入eclipse
Spring Web Flow 2.0 入门 例子源码 -
chenrongtao2132:
melody404 写道请教博主一个问题
登录成功以后为什么老 ...
CAS 单点登录安装笔记4 -- asp.net client端的设置 -
chxiaowu:
从头到尾没发现 那里有 cxf bean配置啊。。。。
WebService开发笔记 3 -- 增强访问 WebService 的安全性 -
chxiaowu:
严重: StandardWrapper.Throwable
o ...
WebService开发笔记 3 -- 增强访问 WebService 的安全性
http://developer.novell.com/documentation/jldap/jldapenu/api/com/novell/ldap/LDAPModification.html
java 代码
java 代码
- //Sample code file: var/ndk/webBuildengine/tmp/viewable_samples/f91a68eb-ad37-4526-92b1-b1938f37b871/ModifyAttrs.java
- //Warning: This code has been marked up for HTML
- /*******************************************************************************
- * $Novell: ModifyAttrs.java,v 1.21 2003/08/21 11:35:10 $
- * Copyright (C) 1999, 2000, 2001 Novell, Inc. All Rights Reserved.
- *
- * THIS WORK IS SUBJECT TO U.S. AND INTERNATIONAL COPYRIGHT LAWS AND
- * TREATIES. USE AND REDISTRIBUTION OF THIS WORK IS SUBJECT TO THE LICENSE
- * AGREEMENT ACCOMPANYING THE SOFTWARE DEVELOPMENT KIT (SDK) THAT CONTAINS
- * THIS WORK. PURSUANT TO THE SDK LICENSE AGREEMENT, NOVELL HEREBY GRANTS TO
- * DEVELOPER A ROYALTY-FREE, NON-EXCLUSIVE LICENSE TO INCLUDE NOVELL'S SAMPLE
- * CODE IN ITS PRODUCT. NOVELL GRANTS DEVELOPER WORLDWIDE DISTRIBUTION RIGHTS
- * TO MARKET, DISTRIBUTE, OR SELL NOVELL'S SAMPLE CODE AS A COMPONENT OF
- * DEVELOPER'S PRODUCTS. NOVELL SHALL HAVE NO OBLIGATIONS TO DEVELOPER OR
- * DEVELOPER'S CUSTOMERS WITH RESPECT TO THIS CODE.
- *
- * $name: ModifyAttrs.java
- *
- * $description: The ModifyAttrs example modifies the attributes of an entry.
- * It also demonstrates the use of an ArrayList to store
- * and indeterminate number of of modifications.
- ******************************************************************************/
- import com.novell.ldap.*;
- import java.util.Date;
- import java.util.ArrayList;
- import java.io.UnsupportedEncodingException;
- public class ModifyAttrs
- {
- public static void main( String[] args )
- {
- int returnCode = 0;
- if (args.length != 4) {
- System.err.println("Usage: java ModifyAttrs
- + ");
- System.err.println("Example: java ModifyAttrs Acme.com "
- + "\"cn=Admin,o=Acme\" secret\n"
- + " \"cn=JSmith,ou=Sales,o=Acme\"");
- System.exit(1);
- }
- int ldapPort = LDAPConnection.DEFAULT_PORT;
- int ldapVersion = LDAPConnection.LDAP_V3;
- Date currentDate = new Date();
- String ldapHost = args[0];
- String loginDN = args[1];
- String password = args[2];
- String dn = args[3];
- LDAPConnection lc = new LDAPConnection();
- ArrayList modList = new ArrayList();
- /* To add a new value to an attribute (creates attribute if necessary)
- * -- Specify the dn of the entry to modify
- * -- Specify the attribute and value to add
- * -- Specify the add modification type
- * -- Add modification to the modification array
- * -- Call LDAPConnection modify() method
- /* To replace values of an attribute (creates attribute if necessary)
- * -- Specify the dn of the entry to modify
- * -- Specify the attribute and new values to replace the old ones
- * -- Specify the replace modification type
- * -- Add modification to the modification array
- * -- Call LDAPConnection modify() method
- /* To delete or modify a single attribute value
- * -- Specify the dn of the entry to modify
- * -- Specify the attribute and value to be modified
- * -- Specify the delete modification type
- * -- Add modification to the modification array
- * -- To add a new value in place of the one we just deleted
- * -- Specify the same attribute and new its value
- * -- Specify the add modification type
- * -- Add modification to the modification array
- * -- Call LDAPConnection modify() method
- */
- String desc =
- "This object was modified at " + new Date( currentDate.getTime());
- // Add a new value to the description attribute
- LDAPAttribute attribute = new LDAPAttribute( "description", desc);
- modList.add( new LDAPModification(LDAPModification.ADD, attribute));
- // Replace all values the E-mail address with a new value
- String email = "James_Smith@Acme.com";
- attribute = new LDAPAttribute( "mail", email);
- modList.add( new LDAPModification(LDAPModification.REPLACE, attribute));
- // Change the phone number
- // First we delete the old phone number
- String phone1= "1 801 555 1212";
- attribute= new LDAPAttribute( "telephoneNumber", phone1);
- modList.add( new LDAPModification(LDAPModification.DELETE, attribute));
- // Now we add the new phone number
- String phone2 = "1 423 555 1212";
- attribute= new LDAPAttribute( "telephoneNumber", phone2);
- modList.add( new LDAPModification(LDAPModification.ADD, attribute));
- LDAPModification[] mods = new LDAPModification[modList.size()];
- mods = (LDAPModification[])modList.toArray(mods);
- try {
- // connect to the server
- lc.connect( ldapHost, ldapPort);
- // bind to the server
- lc.bind( ldapVersion, loginDN, password.getBytes("UTF8") );
- // Add a known phone number value so we have something to change
- lc.modify( dn, new LDAPModification(
- LDAPModification.ADD,
- new LDAPAttribute( "telephoneNumber", "1 801 555 1212")));
- } catch( LDAPException e1) {
- // If phonenumber value already exists, just go on,
- // otherwise it's an error
- if( e1.getResultCode() != LDAPException.ATTRIBUTE_OR_VALUE_EXISTS) {
- System.out.println("Cannot create attribute: " + e1.toString());
- System.exit(1);
- }
- }
- catch( UnsupportedEncodingException e ) {
- System.out.println( "Error: " + e.toString() );
- }
- // Note: All the above modifications will be performed as an atomic
- // unit, if all do not succeed, the operation fails and the
- // directory is unchanged by this operation.
- try {
- lc.modify( dn, mods);
- System.out.println(
- "Successfully modified the attributes of the entry." );
- } catch( LDAPException e2 ) {
- // Tell what happened
- System.err.println( "Error: " + e2.toString() );
- // Indicate the operation failed
- returnCode = 1;
- // Didn't change the directory, delete initial phone number value
- try {
- lc.modify( dn, new LDAPModification( LDAPModification.DELETE,
- new LDAPAttribute( "telephoneNumber", phone1)));
- } catch( Exception e) {
- // ignore
- }
- } finally {
- if( returnCode == 0) {
- try {
- // Cleanup - get rid of the updated description, mail,
- // and telephone attribute values
- // We delete only those values that we added. If the
- // value deleted is the only value of the respective
- // attribute, then the attribute is deleted.
- modList.clear();
- modList.add(new LDAPModification( LDAPModification.DELETE,
- new LDAPAttribute( "description", desc)));
- modList.add(new LDAPModification( LDAPModification.DELETE,
- new LDAPAttribute( "mail", email)));
- modList.add(new LDAPModification( LDAPModification.DELETE,
- new LDAPAttribute( "telephoneNumber", phone2)));
- mods = new LDAPModification[modList.size()];
- mods = (LDAPModification[])modList.toArray(mods);
- lc.modify( dn, mods);
- } catch( Exception e) {
- // ignore
- }
- }
- // Always disconnect
- try {
- lc.disconnect();
- } catch( Exception e) {
- // ignore
- }
- }
- System.exit(returnCode);
- }
- }
发表评论
-
Android开发笔记
2009-10-19 09:11 16761.复制数据库文件: D:\Program Files\and ... -
天气预报的 WebService 服务网站
2009-06-29 10:53 0http://www.webxml.com.cn/WebSer ... -
在 Spring Web Flow 项目中应用 Hessian 服务
2009-05-21 11:19 2610原来作的一个项目因为页面跳转比较多,应用了S ... -
Spring Web Flow 2.0 入门 例子源码
2008-12-22 11:34 11826developerWorks 中有一篇教材讲解了 Spr ... -
JAD反编译工具
2008-05-29 11:33 5076This is README file for Jad - t ... -
压力测试与系统调优
2008-05-04 16:19 2356最近用loadrunne ... -
通过压力测试排查Bug(二)--排查Bug
2008-05-04 11:44 1853最近的一个项目 ... -
通过压力测试排查Bug(一)--测试过程
2008-05-04 11:05 1648最近的一个项目应用了Acegi作为安全框架,项目试运 ... -
WebService开发笔记 3 -- 增强访问 WebService 的安全性
2008-03-19 09:50 21893在WebService开发笔记 1中我们创建了一个WebSer ... -
WebService开发笔记 2 -- VS 2005 访问WebServcie更简单
2008-03-12 19:32 11222WebService开发笔记 2 -- VS 2005 访问W ... -
WebService开发笔记 1 -- 利用cxf开发WebService竟然如此简单
2008-03-12 18:37 27593WebService开发笔记 1 -- 利用cxf开发WebS ... -
Tomcat 配置 -- 打开中文文件名的附件
2008-03-04 10:23 1986设计了文件上传的工具,但在Tomcat服务器上访问中文文件名的 ... -
常用的System.getProperty()
2008-03-02 11:53 29常用的System.getProperty()System.g ... -
CAS 单点登录安装笔记4 -- asp.net client端的设置
2008-03-02 11:51 16548CAS 单点登录安装笔记4 --- asp.net clien ... -
CAS 单点登录安装笔记3 -- 与acegi集成
2008-02-28 23:38 8328CAS 单点登录安装笔记3 -- 与acegi集成 在我的项 ... -
CAS 单点登录安装笔记2 -- 配置CAS,访问自己的用户表
2008-02-27 17:45 7049CAS 单点登录安装笔记2 1.修改cas/webapp/ ... -
CAS 单点登录安装笔记1 -- 基本设置与数字证书的安装
2008-02-26 16:35 5749安装JA-SIG SSO系统笔记1 (关于配置访问数据库的用 ... -
JAVA文档
2007-12-19 16:05 1210JAVA相关文档 http://www.lybbs.net/n ... -
Tomcat性能调优(2)
2007-12-19 15:37 2962原文出处:http://www.lybbs.n ... -
Spring 通过 Tomcat 6.0 下的数据源连接池 访问Oracle数据库
2007-12-17 18:26 6002头疼的老问题,折腾了一天,tomcat6.0数据源配置 to ...
相关推荐
Novell.Directory.Ldap.dll是C#编程中用于访问Directory(目录服务)或eDirectory(Novell的企业级目录服务)的重要组件,它提供了一组丰富的类和方法,使得开发者能够方便地进行目录操作,如查询、添加、删除和修改...
含: com.netscape.sasl.mechanisms.* netscape.ldap.factory.* 请认准再下载
Novell LDAP开发包是专为Java开发者设计的一个工具集,用于与 Lightweight Directory Access Protocol (LDAP) 服务进行交互。LDAP是一种开放的标准协议,用于存储和检索分布式目录信息,广泛应用于企业身份验证、...
import com.novell.ldap.*; public class LDAPSSLExample { public static void main(String[] args) { String ldapUrl = "ldaps://ldap.example.com:636"; String bindDN = "cn=Manager,dc=example,dc=com"; ...
.NET标准LDAP客户端库 -开发版本-Win2019 / Linux / MacOS CI -维护版本-Win2019 / Linux / MacOS CI LDAP客户端库-与.NET Standard 2.0 / 2.1和.NET5兼容的.NET平台:.NET5,.NET Core> = 2.0,.NET Framework> = ...
在Java开发中,`com.sun.jndi.ldap.jar`是一个重要的库文件,它包含了Java Naming and Directory Interface (JNDI) 的 LDAP(Lightweight Directory Access Protocol)实现。JNDI是一个接口,提供了一种标准的方式来...
spring-ldap-core-1.3.0.RELEASE.jar
含 org.apache.jmeter.protocol.ldap.config.* org.apache.jmeter.protocol.ldap.control.* org.apache.jmeter.protocol.ldap.sampler.*
**Java Naming and Directory Interface (JNDI) 是一个Java API,用于访问各种命名和目录服务。JNDI 提供了一种统一的接口,使得Java应用程序能够查找和操作各种类型的资源,如数据源、邮件服务器、对象等。在“jndi...
Softerra LDAP Administrator 2019.1 最新版本,功能齐全,稳定
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, "ldap://localhost:389"); env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put...
【LDAP安装说明(windows)】 LDAP(Lightweight Directory Access ...接下来,你可以使用LdapBrowser或其他工具进行目录的管理和查询,或者开发与LDAP集成的应用程序。注意定期更新软件和补丁,确保系统安全性和性能。
标题“ldapbrowser-4.5.10625.0-x64-eng”指的是一个名为“ldapbrowser”的软件的特定版本,版本号为4.5.10625.0,适用于64位操作系统,并且是英文版本。这个软件的主要功能是允许用户方便地查看和操作 Lightweight ...
在windows系统上搭建并配置一个LDAP服务器的LDAP admin连接工具。
标签“技术”表明本文档的内容属于技术类别,涉及到 Java、LDAP 和 Active Directory 等技术领域。 三、部分内容 部分内容可以分为以下几个部分: 1. LDAP 和 Active Directory LDAP(Lightweight Directory ...
《LDAP编程与Java》这本书是关于使用Java进行 Lightweight Directory Access Protocol (LDAP) 开发的指南。LDAP是一种开放标准的网络协议,用于访问和管理分布式目录服务。它在企业级应用中广泛使用,如用户身份验证...
Python库ldap0-1.4.1.tar.gz是针对LDAP(轻量级目录访问协议)进行操作的一个Python实现。在IT行业中,理解并熟练使用这样的库对于开发与管理分布式身份验证、授权和信息存储系统至关重要。这篇详尽的介绍将深入探讨...
基于java的开发源码-开源LDAP浏览器 JXplorer.zip 基于java的开发源码-开源LDAP浏览器 JXplorer.zip 基于java的开发源码-开源LDAP浏览器 JXplorer.zip 基于java的开发源码-开源LDAP浏览器 JXplorer.zip 基于java的...
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, "ldap://localhost:389"); env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put...