??xml version="1.0" encoding="utf-8" standalone="yes"?>一本久久a久久精品亚洲,亚洲综合男人的天堂色婷婷,中日韩亚洲人成无码网站http://www.tkk7.com/junky/category/23004.htmlzh-cnThu, 12 Jul 2007 18:54:21 GMTThu, 12 Jul 2007 18:54:21 GMT60SQL SERVER 关于外联?Outer Join)及其?/title><link>http://www.tkk7.com/junky/archive/2007/07/12/129852.html</link><dc:creator>junky</dc:creator><author>junky</author><pubDate>Thu, 12 Jul 2007 07:44:00 GMT</pubDate><guid>http://www.tkk7.com/junky/archive/2007/07/12/129852.html</guid><wfw:comment>http://www.tkk7.com/junky/comments/129852.html</wfw:comment><comments>http://www.tkk7.com/junky/archive/2007/07/12/129852.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/junky/comments/commentRss/129852.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/junky/services/trackbacks/129852.html</trackback:ping><description><![CDATA[<p><strong>一 使用外联?/strong></p> <p>  以前在Oracle中用=(+)?+)=来进行左外联接和叛_联接Q后来用SQL Server时用*=?*q行外连接左外联接和叛_联接Q?br>现在军_用SQL-92的标准方法:[OUTER] JOINQOUTER是可以省略的?/p> <p>  LEFT OUTER JOIN ?nbsp;LEFT JOIN        表示左外联接 </p> <p>  RIGHT OUTER JOIN ?nbsp;RIGHT JOIN   表示左外联接 </p> <p>  FULL OUTER JOIN ?nbsp;FULL JOIN        表示左外联接</p> <p>  外联接的意思不用多_我们都懂Q但是JOIN到底怎么用呢Q没有找到很好的资料Q只能从例子中学习了Q?/p> <p>  1、这个例子也许没有实际意义,只是Z说明问题Q?/p> <div style="SCROLLBAR-HIGHLIGHT-COLOR: buttonhighlight; OVERFLOW: auto; WIDTH: 500px"> <pre style="BORDER-RIGHT: black 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: black 1px solid; PADDING-LEFT: 4px; PADDING-BOTTOM: 4px; BORDER-LEFT: black 1px solid; PADDING-TOP: 4px; BORDER-BOTTOM: black 1px solid; BACKGROUND-COLOR: #ededed"> <div><span style="COLOR: #000000">CREATE TABLE orders(order_id </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">, firm_id </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">, p_id </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">) CREATE TABLE firms (firm_id </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">, f_name </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">) CREATE TABLE products(p_id </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">, p_name </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">) select a.order_id, b.f_name, c.p_name from orders a left join firms b on a.firm_id </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> b.firm_id left join products c on a.p_id </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> c.p_id</span></div> </pre> </div> <p>  说明Qorders表是主表Q先和从表firmsq行左联接,再和从表productsq行左联接?/p> <p>  判断是外联接中的主表q是从表主要看from从句中各个表在LEFT JOIN或RIGHT JOIN两边的位|:LEFT JOIN左边的表是主表,RIGHT JOIN双的表是主表;</p> <p>  ON表达了两个表q接的条Ӟ一般外联接是等D接,不等D接意义不大;</p> <p>  在多个表的连接中Q一个表既可以做主表又同时可以做从表Qؓ了说明这个问题,我们修改以上SQL为:</p> <div style="SCROLLBAR-HIGHLIGHT-COLOR: buttonhighlight; OVERFLOW: auto; WIDTH: 500px"> <pre style="BORDER-RIGHT: black 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: black 1px solid; PADDING-LEFT: 4px; PADDING-BOTTOM: 4px; BORDER-LEFT: black 1px solid; PADDING-TOP: 4px; BORDER-BOTTOM: black 1px solid; BACKGROUND-COLOR: #ededed"> <div><span style="COLOR: #000000">select a.order_id, b.f_name, c.p_name from orders a left join firms b on a.firm_id </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> b.firm_id right join products c on a.order_id </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> c.p_id</span></div> </pre> </div> <p>  q个SQL没有什么意义,但从中可以看出a表既是b的主表又是c的从表;到底怎么用,q是要根据实际情冉|军_是左联接q是双接;</p> <p>  那天Q看Cq样一个例子:</p> <div style="SCROLLBAR-HIGHLIGHT-COLOR: buttonhighlight; OVERFLOW: auto; WIDTH: 500px"> <pre style="BORDER-RIGHT: black 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: black 1px solid; PADDING-LEFT: 4px; PADDING-BOTTOM: 4px; BORDER-LEFT: black 1px solid; PADDING-TOP: 4px; BORDER-BOTTOM: black 1px solid; BACKGROUND-COLOR: #ededed"> <div><span style="COLOR: #000000">create table tab1 (c1 </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">, c2 </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">, c3 </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">) create table tab2 (c1 </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">, c2 </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">, c3 </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">) create table tab3 (c1 </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">, c2 </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">, c3 </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">) create table tab4 (c1 </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">, c2 </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">, c3 </span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">) SELECT </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> FROM tab1 LEFT OUTER JOIN tab2 ON tab1.c3 </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> tab2.c3 left OUTER JOIN tab3 right OUTER JOIN tab4 ON tab3.c1 </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> tab4.c1 ON tab2.c3 </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> tab4.c3</span></div> </pre> </div> <p>  q种用法q真见Q具体怎么个意思,q在理解?..我把它改写成Q?/p> <div style="SCROLLBAR-HIGHLIGHT-COLOR: buttonhighlight; OVERFLOW: auto; WIDTH: 500px"> <pre style="BORDER-RIGHT: black 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: black 1px solid; PADDING-LEFT: 4px; PADDING-BOTTOM: 4px; BORDER-LEFT: black 1px solid; PADDING-TOP: 4px; BORDER-BOTTOM: black 1px solid; BACKGROUND-COLOR: #ededed"> <div><span style="COLOR: #000000">SELECT </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> FROM tab1 left JOIN tab2 ON tab1.c3 </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> tab2.c3 LEFT OUTER JOIN tab4 ON tab2.c3 </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> tab4.c3 RIGHT OUTER JOIN tab3  ON tab3.c1 </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> tab4.c1</span></div> </pre> </div> <p>  也许它们是一个意思。我发现加个括号Q看的更清楚一些(它是个嵌套)</p> <div style="SCROLLBAR-HIGHLIGHT-COLOR: buttonhighlight; OVERFLOW: auto; WIDTH: 500px"> <pre style="BORDER-RIGHT: black 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: black 1px solid; PADDING-LEFT: 4px; PADDING-BOTTOM: 4px; BORDER-LEFT: black 1px solid; PADDING-TOP: 4px; BORDER-BOTTOM: black 1px solid; BACKGROUND-COLOR: #ededed"> <div><span style="COLOR: #000000">SELECT </span><span style="COLOR: #000000">*</span><span style="COLOR: #000000"> FROM tab1 LEFT OUTER JOIN tab2 ON tab1.c3 </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> tab2.c3 left OUTER JOIN (tab3 right OUTER JOIN tab4 ON tab3.c1 </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> tab4.c1) ON tab2.c3 </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> tab4.c3</span></div> </pre> </div> <p>  <strong>?nbsp;外联接中 "ON + AND" ?nbsp;"ON + WHERE" 的区?/strong></p> <p>  1、on条g是外联接时在生成临时表时使用的联l条Ӟ不论从表是确定D是NULLQ主表所有的值都会出玎ͼ</p> <p>  如果再加上and条gQ?nbsp;如果and条g引用的是主表的列Q则对结果毫无媄响,主表的所有纪录依然会全部出现Q如果and条g引用的是从表的列Q则不符合条件的从表U录昄NULLQ?/p> <p>  2、where条g是在临时表生成后Q再对时表q行qo的条件。时表中的所有纪录都受媄响,不符合条件的U录被过滤出l果集;</p> <p>  3、示例:</p> <div style="SCROLLBAR-HIGHLIGHT-COLOR: buttonhighlight; OVERFLOW: auto; WIDTH: 500px"> <pre style="BORDER-RIGHT: black 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: black 1px solid; PADDING-LEFT: 4px; PADDING-BOTTOM: 4px; BORDER-LEFT: black 1px solid; PADDING-TOP: 4px; BORDER-BOTTOM: black 1px solid; BACKGROUND-COLOR: #ededed"> <div><span style="COLOR: #000000">select a.module_id, a.name, b.module_name from fb_autocoding a left join fb_app_module b on a.module_id </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> b.module_id and b.module_internal_label </span><span style="COLOR: #000000"><></span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">LO</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">; select a.module_id, a.name, b.module_name from fb_autocoding a left join fb_app_module b on a.module_id </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> b.module_id where b.module_internal_label </span><span style="COLOR: #000000"><></span><span style="COLOR: #000000"> </span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">LO</span><span style="COLOR: #000000">'</span><span style="COLOR: #000000">; </span></div> </pre> </div> <p>  <strong>?nbsp;其他Joinq算</strong></p> <p>  merge joinQ在处理其他联结之前Q先把相关两个表联结在一P</p> <p>  hash joinQ把一个表join到已l被执行qjoin的结果上Q?/p> <p>  用括h变join的顺序:</p> <div style="SCROLLBAR-HIGHLIGHT-COLOR: buttonhighlight; OVERFLOW: auto; WIDTH: 500px"> <pre style="BORDER-RIGHT: black 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: black 1px solid; PADDING-LEFT: 4px; PADDING-BOTTOM: 4px; BORDER-LEFT: black 1px solid; PADDING-TOP: 4px; BORDER-BOTTOM: black 1px solid; BACKGROUND-COLOR: #ededed"> <div><span style="COLOR: #000000">select catalog.item, catalog.item_color, product.item, color.color_name from catalog full outer join (product cross join color) on catalog.item </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> product.item and catalog.item_color </span><span style="COLOR: #000000">=</span><span style="COLOR: #000000"> color.color_name;</span></div> </pre> </div> <div style="DISPLAY: none">1</div> <img src ="http://www.tkk7.com/junky/aggbug/129852.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/junky/" target="_blank">junky</a> 2007-07-12 15:44 <a href="http://www.tkk7.com/junky/archive/2007/07/12/129852.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Microsoft LDAP 错误代码 http://www.tkk7.com/junky/archive/2007/06/26/126308.htmljunkyjunkyTue, 26 Jun 2007 04:08:00 GMThttp://www.tkk7.com/junky/archive/2007/06/26/126308.htmlhttp://www.tkk7.com/junky/comments/126308.htmlhttp://www.tkk7.com/junky/archive/2007/06/26/126308.html#Feedback0http://www.tkk7.com/junky/comments/commentRss/126308.htmlhttp://www.tkk7.com/junky/services/trackbacks/126308.htmlhttp://support.microsoft.com/kb/218185/

Microsoft Windows 2000 Active Directory 使用 Internet 标准的轻量目录讉K协议 (LDAP) 来访问信息。在响应各种 LDAP hӞ域控制器会返回包含域 LDAP 错误代码的响应,q些错误代码指示协议操作的状态。本文将介绍q些错误代码?/font>


下表描述了这些错误代码?
     代码                               ?     说明
---------------------------------------------------------------------------
LDAP_SUCCESS                      0x00   h成功?
LDAP_OPERATIONS_ERROR             0x01   LDAP 库初始化p|?
LDAP_PROTOCOL_ERROR               0x02   出现协议错误?
LDAP_TIMELIMIT_EXCEEDED           0x03   出旉限制?
LDAP_SIZELIMIT_EXCEEDED           0x04   出大小限制?
LDAP_COMPARE_FALSE                0x05   比较l果?FALSE?
LDAP_COMPARE_TRUE                 0x06   比较l果?TRUE?
LDAP_AUTH_METHOD_NOT_SUPPORTED    0x07   不支持此w䆾验证Ҏ?
LDAP_STRONG_AUTH_REQUIRED         0x08   需要加强的w䆾验证?
LDAP_REFERRAL_V2                  0x09   LDAP 版本 2 索?
LDAP_PARTIAL_RESULTS              0x09   接收到部分结果和索?
LDAP_REFERRAL                     0x0a   出现索?
LDAP_ADMIN_LIMIT_EXCEEDED         0x0b   出服务器上的管理限制?
LDAP_UNAVAILABLE_CRIT_EXTENSION   0x0c   没有_֯扩展?
LDAP_CONFIDENTIALITY_REQUIRED     0x0d   需要保密?
LDAP_NO_SUCH_ATTRIBUTE            0x10   h的属性不存在?
LDAP_UNDEFINED_TYPE               0x11   cd未定义?
LDAP_INAPPROPRIATE_MATCHING       0x12   出现不适当的匹配?
LDAP_CONSTRAINT_VIOLATION         0x13   出现U束冲突?
LDAP_ATTRIBUTE_OR_VALUE_EXISTS    0x14   属性已存在或已被赋倹{?
LDAP_INVALID_SYNTAX               0x15   语法无效?
LDAP_NO_SUCH_OBJECT               0x20   对象不存在?br>
ld_matched 在LDAP_NO_SUCH_OBJECT
错误q回事g中,q个参数包含DN匚w的程度; LDAP_ALIAS_PROBLEM 0x21 别名无效? LDAP_INVALID_DN_SYNTAX 0x22 辨别名的语法无效? LDAP_IS_LEAF 0x23 该对象ؓ叶对象? LDAP_ALIAS_DEREF_PROBLEM 0x24 无法取消对别名的引用? LDAP_INAPPROPRIATE_AUTH 0x30 w䆾验证不正? LDAP_INVALID_CREDENTIALS 0x31 提供的凭据无效? LDAP_INSUFFICIENT_RIGHTS 0x32 用户无够的讉K权限? LDAP_BUSY 0x33 服务器忙? LDAP_UNAVAILABLE 0x34 服务器不可用? LDAP_UNWILLING_TO_PERFORM 0x35 服务器不处理目录h? LDAP_LOOP_DETECT 0x36 引用铑@环回臛_用服务器? LDAP_NAMING_VIOLATION 0x40 存在命名冲突? LDAP_OBJECT_CLASS_VIOLATION 0x41 存在对象cd冲突? LDAP_NOT_ALLOWED_ON_NONLEAF 0x42 不允许在非叶对象上操作? LDAP_NOT_ALLOWED_ON_RDN 0x43 不允许在 RDN 上操作? LDAP_ALREADY_EXISTS 0x44 对象已存在? LDAP_NO_OBJECT_CLASS_MODS 0x45 无法修改对象cd? LDAP_RESULTS_TOO_LARGE 0x46 q回的结果太大? LDAP_AFFECTS_MULTIPLE_DSAS 0x47 多个目录服务代理受到影响? LDAP_OTHER 0x50 出现未知错误? LDAP_SERVER_DOWN 0x51 无法联系 LDAP 服务器? LDAP_LOCAL_ERROR 0x52 出现本地错误? LDAP_ENCODING_ERROR 0x53 出现~码错误? LDAP_DECODING_ERROR 0x54 出现解码错误? LDAP_TIMEOUT 0x55 搜烦时? LDAP_AUTH_UNKNOWN 0x56 出现未知的n份验证错误? LDAP_FILTER_ERROR 0x57 搜烦{选器不正? LDAP_USER_CANCELLED 0x58 用户已取消操作? LDAP_PARAM_ERROR 0x59 传递给例程的参C正确? LDAP_NO_MEMORY 0x5a pȝ内存不? LDAP_CONNECT_ERROR 0x5b 无法建立到服务器的连接? LDAP_NOT_SUPPORTED 0x5c 不支持此功能? LDAP_CONTROL_NOT_FOUND 0x5d ldap 函数找不到指定控件? LDAP_NO_RESULTS_RETURNED 0x5e 不支持此功能? LDAP_MORE_RESULTS_TO_RETURN 0x5f 返回其他结果? LDAP_CLIENT_LOOP 0x60 到客户循环? LDAP_REFERRAL_LIMIT_EXCEEDED 0x61 出索限制? LDAP_SASL_BIND_IN_PROGRESS 0x0E 多阶D늻定的中间l定l果

q篇文章中的信息适用?
? Microsoft Windows 2000 Server
? Microsoft Windows 2000 Advanced Server
? Microsoft Windows 2000 Datacenter Server
详细的英文解释:

蓝色是我的翻译,U色是不能确定的译文字Q黑色嘛Q是原文?/span>

Hex Decimal Constant: Description
0×00 0 LDAP_SUCCESS: Indicates the requested client operation completed successfully.
成功Q没什么好说的了?/font>
0×01 1 LDAP_OPERATIONS_ERROR: Indicates an internal error. The server is unable to respond with a more specific error and is also unable to properly respond to a request. It does not indicate that the client has sent an erroneous message.
一个内部错误。Server无法正确?respond 一个requestQ也无法生成说明错误cd?respond 。它不代表client 发送了错误的消息?/font> In NDS 8.3x through NDS 7.xx, this was the default error for NDS errors that did not map to an LDAP error code. To conform to the new LDAP drafts, NDS 8.5 uses 80 (0×50) for such errors.
In NDS 8.3x through NDS 7.xx, q是一个没有映到 LDAP错误码的NDS~省错误。ؓ了符合新?LDAP草案QNDS 8.5使用80 (0×50) 代表q个错误?/font>
0×02 2 LDAP_PROTOCOL_ERROR: Indicates that the server has received an invalid or malformed request from the client.
Server ?client 收到了一个无效的或者格式不正确的request ?/font>
0×03 3 LDAP_TIMELIMIT_EXCEEDED: Indicates that the operation’s time limit specified by either the client or the server has been exceeded. On search operations, incomplete results are returned.
出?Server或者Client指定的时间限制。当q行 serach的时候,q回不完全的l果?/font>
0×04 4 LDAP_SIZELIMIT_EXCEEDED: Indicates that in a search operation, the size limit specified by the client or the server has been exceeded. Incomplete results are returned.
在查询的时候,出了Server或?Client指定的size限制。返回不完全的结果?
0×05 5 LDAP_COMPARE_FALSE: Does not indicate an error condition. Indicates that the results of a compare operation are false.
不是错误状态。表C比较操作的l果?false ?/font>
0×06 6 LDAP_COMPARE_TRUE: Does not indicate an error condition. Indicates that the results of a compare operation are true.
不是错误状态。表C比较操作的l果?true ?/font>
0×07 7 LDAP_AUTH_METHOD_NOT_SUPPORTED: Indicates that during a bind operation the client requested an authentication method not supported by the LDAP server.
当进行bind操作Ӟ client指定的认证方式不被LDAP Server支持?/font>
0×08 8 LDAP_STRONG_AUTH_REQUIRED: Indicates one of the following:

  • In bind requests, the LDAP server accepts only strong authentication.
  • In a client request, the client requested an operation such as delete that requires strong authentication.
  • In an unsolicited notice of disconnection, the LDAP server discovers the security protecting the communication between the client and server has unexpectedly failed or been compromised.

代表下列情况之一Q?/font>

0×09 9 Reserved.
保留?/font>
0×0A 10 LDAP_REFERRAL: Does not indicate an error condition. In LDAPv3, indicates that the server does not hold the target entry of the request, but that the servers in the referral field may.
不是错误状态。在LDAPv3 中,代表Server无法得到h的Entry 目标Q?/font>但是可以介绍一个可能得到的?field)?/font>
0×0B 11 LDAP_ADMINLIMIT_EXCEEDED: Indicates that an LDAP server limit set by an administrative authority has been exceeded.
LDAP Server 的被权限理指定的有限集合被出?/font>
0×0C 12 LDAP_UNAVAILABLE_CRITICAL_EXTENSION: Indicates that the LDAP server was unable to satisfy a request because one or more critical extensions were not available. Either the server does not support the control or the control is not appropriate for the operation type.
LDAP Server不支持的request Q因Z个或者多?/font>重要的扩展是不允许的。Server 不支持的Control或?/font>Control 对于操作是不恰当的?/font>
0×0D 13 LDAP_CONFIDENTIALITY_REQUIRED: Indicates that the session is not protected by a protocol such as Transport Layer Security (TLS), which provides session confidentiality.
Session没有被诸如Transport Layer Security (TLS) 之类的协议保护,无法提供Session机密性?/font>
0×0E 14 LDAP_SASL_BIND_IN_PROGRESS: Does not indicate an error condition, but indicates that the server is ready for the next step in the process. The client must send the server the same SASL mechanism to continue the process.
不是错误状态,代表Server已经?process的下一步做好了准备。Client必须发送相同的 SASLlServer以lprocess ?/font>
0×0F 15 Not used.
未用?/font>
0×10 16 LDAP_NO_SUCH_ATTRIBUTE: Indicates that the attribute specified in the modify or compare operation does not exist in the entry.
在modify或?compare操作中指定的属性,在指定Entry中不存在?/font>
0×11 17 LDAP_UNDEFINED_TYPE: Indicates that the attribute specified in the modify or add operation does not exist in the LDAP server’s schema.
在modify或?add操作中指定的属性,在LDAP Server?Schema中不存在?/font>
0×12 18 LDAP_INAPPROPRIATE_MATCHING: Indicates that the matching rule specified in the search filter does not match a rule defined for the attribute’s syntax.
在Search Filter 中指定的 rule不能和syntax中的rule 定义匚w?/font>
0×13 19 LDAP_CONSTRAINT_VIOLATION: Indicates that the attribute value specified in a modify, add, or modify DN operation violates constraints placed on the attribute. The constraint can be one of size or content (string only, no binary).
在modify?/font> add或者modify DN 操作中指定的属性|触犯了属性中的限制。那些限制是内容长度或者内容只能是StringQ不能是binary {?/font>
0×14 20 LDAP_TYPE_OR_VALUE_EXISTS: Indicates that the attribute value specified in a modify or add operation already exists as a value for that attribute.
在modify或?/font> add操作中指定的属性|在属性中已经存在了?/font>
0×15 21 LDAP_INVALID_SYNTAX: Indicates that the attribute value specified in an add, compare, or modify operation is an unrecognized or invalid syntax for the attribute.
在add?compare或者modify 操作中指定的属性|是不认识或者无效的 syntax ?/font>
22-31 Not used.
未用?/font>
0×20 32 LDAP_NO_SUCH_OBJECT: Indicates the target object cannot be found. This code is not returned on following operations:

  • Search operations that find the search base but cannot find any entries that match the search filter.
  • Bind operations.

无法扑ֈ目标Object 。在以下操作中不q回q个代码Q?

  • Search操作中没有找CQ何匹?/span>serach filter ?/span>entry?/span>
  • Bind操作?/span>
0×21 33 LDAP_ALIAS_PROBLEM: Indicates that an error occurred when an alias was dereferenced.
当一个别名被复引用时发生错误?/font>
0×22 34 LDAP_INVALID_DN_SYNTAX: Indicates that the syntax of the DN is incorrect. (If the DN syntax is correct, but the LDAP server’s structure rules do not permit the operation, the server returns LDAP_UNWILLING_TO_PERFORM.)
DN的句法不寏V? 如果DN句法正确Q但是LDAP Server 的结构规则不许可q个操作QServerq回LDAP_UNWILLING_TO_PERFORM ?)
0×23 35 LDAP_IS_LEAF: Indicates that the specified operation cannot be performed on a leaf entry. (This code is not currently in the LDAP specifications, but is reserved for this constant.)
指定的操作不能被实施于一个叶子Entry 上? q个错误码不在当前的LDAP 规范中,但是q个常数为此而保留?)
0×24 36 LDAP_ALIAS_DEREF_PROBLEM: Indicates that during a search operation, either the client does not have access rights to read the aliased object’s name or dereferencing is not allowed.
在search 操作中, client无权?/font>别名了的 对象名或者间接引用是不被许可的?/font>
37-47 Not used.
未用?/font>
0×30 48 LDAP_INAPPROPRIATE_AUTH: Indicates that during a bind operation, the client is attempting to use an authentication method that the client cannot use correctly. For example, either of the following cause this error:

  • The client returns simple credentials when strong credentials are required.
  • The client returns a DN and a password for a simple bind when the entry does not have a password defined.

当bind操作q程中, client试图使用不正的认证方式。例如,以下情况造成q个errorQ?

  • Clientq回单认证当需?/span>strong credentials 的时候?/span>
  • Clientq回 DN和密码ؓ了简单认证,但是 entry没有定义密码?/span>
0×31 49 LDAP_INVALID_CREDENTIALS: Indicates that during a bind operation one of the following occurred:

  • The client passed either an incorrect DN or password.
  • The password is incorrect because it has expired, intruder detection has locked the account, or some other similar reason.

当bind操作q程中发生以下情况:

  • Client传送不正确?/span>DN或?/span> password ?/span>
  • 密码不正,因ؓ它过期了Q入侉|锁住了帐号Q或者其他类似原因?/span>
0×32 50 LDAP_INSUFFICIENT_ACCESS: Indicates that the caller does not have sufficient rights to perform the requested operation.
调用者没有够的权限执行h的操作?/font>
0×33 51 LDAP_BUSY: Indicates that the LDAP server is too busy to process the client request at this time but if the client waits and resubmits the request, the server may be able to process it then.
LDAP Server太忙以至于无法处理client 的请求,但是如果client{待然后重新提交hQServer 可能会处理?/font>
0×34 52 LDAP_UNAVAILABLE: Indicates that the LDAP server cannot process the client’s bind request, usually because it is shutting down.
LDAP Server不能处理client 的bindhQ通常是因为它down Z?/font>
0×35 53 LDAP_UNWILLING_TO_PERFORM: Indicates that the LDAP server cannot process the request because of server-defined restrictions. This error is returned for the following reasons:

  • The add entry request violates the server’s structure rules.
  • The modify attribute request specifies attributes that users cannot modify.
  • Password restrictions prevent the action.
  • Connection restrictions prevent the action.

LDAP Server不能处理request Q因为Server定义的限制?/font>
q个错误在以下原因下发生Q?/font>

0×36 54 LDAP_LOOP_DETECT: Indicates that the client discovered an alias or referral loop, and is thus unable to complete this request.
client 发现一个别名或者引用是循环的,Dq个request 无法完成?/font>
55-63 Not used.
未用?/font>
0×40 64 LDAP_NAMING_VIOLATION: Indicates that the add or modify DN operation violates the schema’s structure rules. For example,

  • The request places the entry subordinate to an alias.
  • The request places the entry subordinate to a container that is forbidden by the containment rules.
  • The RDN for the entry uses a forbidden attribute type.

?add或?modify DN操作中违反Schema的结构规则。例如:

  • h攄entry在别名下
  • h攄entry在被包含规则止的容器中
  • Entry?/span>RDN使用了禁止的属性类?/span>
0×41 65 LDAP_OBJECT_CLASS_VIOLATION: Indicates that the add, modify, or modify DN operation violates the object class rules for the entry. For example, the following types of request return this error:

  • The add or modify operation tries to add an entry without a value for a required attribute.
  • The add or modify operation tries to add an entry with a value for an attribute which the class definition does not contain.
  • The modify operation tries to remove a required attribute without removing the auxiliary class that defines the attribute as required.

?add?modify或者modify DN操作中违?entry的object class规则。例如,下面cd?requestDq个错误Q?/font>

0×42 66 LDAP_NOT_ALLOWED_ON_NONLEAF: Indicates that the requested operation is permitted only on leaf entries. For example, the following types of requests return this error:

  • The client requests a delete operation on a parent entry.
  • The client request a modify DN operation on a parent entry.

h的操作只允许在叶子entry上执行。例如下面类型的 requestDq个错误Q?/font>

0×43 67 LDAP_NOT_ALLOWED_ON_RDN: Indicates that the modify operation attempted to remove an attribute value that forms the entry’s relative distinguished name.
modify操作试图删除兌着DN 的属性倹{?/font>
0×44 68 LDAP_ALREADY_EXISTS: Indicates that the add operation attempted to add an entry that already exists, or that the modify operation attempted to rename an entry to the name of an entry that already exists.
add操作试图加一个已l存在的Entry Q或者modify操作试图重命名Entry Z个已l存在的entry的名字?/font>
0×45 69 LDAP_NO_OBJECT_CLASS_MODS: Indicates that the modify operation attempted to modify the structure rules of an object class.
modify操作试图改变object class 的结构规则?/font>
0×46 70 LDAP_RESULTS_TOO_LARGE: Reserved for CLDAP.
为CLDAP保留?/font>
0×47 71 LDAP_AFFECTS_MULTIPLE_DSAS: Indicates that the modify DN operation moves the entry from one LDAP server to another and thus requires more than one LDAP server.
modify DN的操作移动Entry 从一个LDAP Server到另一个,造成需要超q一个LDAP Server ?/font>
72-79 Not used.
未?/font>
0×50 80 LDAP_OTHER: Indicates an unknown error condition. This is the default value for NDS error codes which do not map to other LDAP error codes.
一个未知的error状态。这?NDS中没有映到其他LDAP错误码上的错误码的缺省倹{?/font>


junky 2007-06-26 12:08 发表评论
]]>
LDAPErrorCodeshttp://www.tkk7.com/junky/archive/2007/06/26/126279.htmljunkyjunkyTue, 26 Jun 2007 02:33:00 GMThttp://www.tkk7.com/junky/archive/2007/06/26/126279.htmlhttp://www.tkk7.com/junky/comments/126279.htmlhttp://www.tkk7.com/junky/archive/2007/06/26/126279.html#Feedback0http://www.tkk7.com/junky/comments/commentRss/126279.htmlhttp://www.tkk7.com/junky/services/trackbacks/126279.html阅读全文

junky 2007-06-26 10:33 发表评论
]]>
OpenLDAP快速上??http://www.tkk7.com/junky/archive/2007/06/06/122379.htmljunkyjunkyWed, 06 Jun 2007 07:45:00 GMThttp://www.tkk7.com/junky/archive/2007/06/06/122379.htmlhttp://www.tkk7.com/junky/comments/122379.htmlhttp://www.tkk7.com/junky/archive/2007/06/06/122379.html#Feedback0http://www.tkk7.com/junky/comments/commentRss/122379.htmlhttp://www.tkk7.com/junky/services/trackbacks/122379.htmlOpenLDAP 快速上?/span>

   Ben 的项目里面要用到 OpenLDAP, 我的目里面也要用到 LDAP, 所以这 2 天集中看了一?/span> LDAP 相关的内宏V做了个W记Q也是Zhcȝ识的U篏做点或有或无的A献?/span>

   OpenLDAP 的官方站Ҏ http://www.openldap.org ?/span>

       上面有个 QuickStart, 我将大致按照q个来讲解?/span>

一?/span> 安装
在官方站点上发布的是 linux/unix 下的 OpenLDAP 源文Ӟ当然也很Ҏ扑ֈ windows pȝ下的版本。笔者学习安装的是 windows 版本的?/span>

二?/span> 配置

OpenLDAP ?/span> 2 个用hx的配|文件?/span>

一个是 slapd.conf Q?/span> 在他里面定义了最基本?/span> DN 以及理员的账号和密码?/span>

另一个是 LDIF 的文件。在它里面可以配|所有的用户和组l?/span>

1?nbsp;我们先来了解 LDAP 的相xc?/span>
我们知道 LDAP 的全UCؓQ?/span> Lightweight Directory Access Protocol Q,卌量目录讉K协议?/span>

Ldap 是怎样的一个结构呢 Q用官方的话_“ In LDAP, directory entries are arranged in a hierarchical tree-like structure. Traditionally, this structure reflected the geographic and/or organizational boundaries. Entries representing countries appear at the top of the tree. Below them are entries representing states and national organizations. Below them might be entries representing organizational units, people, printers, documents, or just about anything else you can think of.. ”他是一个树状的l构。每一个节点被UCؓ一?/span> Entry 。这?/span> Entry 有着有趣的含义?/span>

下面是他?/span> 2 个实例。一个反映了 geographic Q一个反映了 organizational ?br>
                                                           传统命名

                                                           |络命名

我们来看看个个节点的定义方式?/span>

每个 Entry 都有一个自己得一个标C?/span> Q我们把他叫 DN(Distinguished Name) Q这?/span> dn 包含了一?/span> RDN Q?/span> Relative Distinguished Name Q。在上面的第二个图例 中,Barbara Jensen的RDN?/span> uid=babsQ他的dn?/span> uid=babs,ou=People,dc=example, dc=com?/span>

每个节点都需要一个类?/span> Q?/span> q个cd信息?span>objectClass来表C。ObjectClass是该节点的schema,他定义了该节点该有和不该有的属性。默认的objectClass都在schema/core.schema中有定义。如果在你的配置q程中出C关于找不到objectClass的问题,您不妨参看一下这里面有没有你用到的objectClass . 在schema文g夹下q有其他一些schema文g,你也可以定义自己的schema.惌加蝲其他的schema,你可以在slapd.conf文g中用include加入.?include  ./schema/core.schema. Z方便识别Q其实我们在DN里面用的都是objectClass的简写Ş式。如Qou代表organizationUnitQc代表country,st代表state,dc代表Q?{?/span>

2?nbsp;来看?/span> slapd.conf q个文g
q个文g的主要信息是如下几行Q?/span>

database bdb

suffix "dc=<MY-DOMAIN>,dc=<COM>"

rootdn "cn=Manager,dc=<MY-DOMAIN>,dc=<COM>"

rootpw secret

directory /usr/local/var/openldap-data

定义了数据库Q最基本的后~Q管理员?/span> dn 和密码,以及数据存放路径?/span>

~辑好这个文Ӟ我们可以启动了?/span>

如果你把 ldap 安装?/span> windows 服务Q你可以像我一样启动:

net start OpenLDAP-slapd

 

3?nbsp;我们主要操作的就是这?/span> LDIF 文g
我们需要在q个文g里面加入所需要的 dn.

注意Q因为我们在 slapd.conf 中定义了一?/span> base dn 和一个管理员 dn Q所以我们需要首先把q?/span> 2 ?/span> dn 加进来?/span>

dn: dc=<MY-DOMAIN>,dc=<COM>

objectclass: dcObject

objectclass: organization

o: <MY ORGANIZATION>

dc: <MY-DOMAIN>

 

dn: cn=Manager,dc=<MY-DOMAIN>,dc=<COM>

objectclass: organizationalRole

cn: Manager

保存?/span> ldif 后缀的文件。然后我们用命o把这些信息加?/span> ldap 中去Q?/span>

ldapadd -x -D "cn=Manager,dc=<MY-DOMAIN>,dc=<COM>" -W -f example.ldif

让我们来查看以下我们的设|是否出现问题:

ldapsearch -x -b 'dc=example,dc=com' '(objectclass=*)'

上面的是 linux/unix 下的命oQ?/span> windows 下我们需要做Ҏ改:

ldapsearch -x -b dc=example,dc=com (objectclass=*)

对,是L引号?/span>

Z察看方便Q笔者徏议?/span> GUI 工具来查看,比如W者用的 Softerra LDAP Browser 2.6 ?/span>

 

三?/span> ?/span> java 集成
我们?/span> ldap Server 已经搭徏h了,我们需要在我们?/span> java E序中访问这个服务?/span>

Openldap.org 上有没有Ԍ有讲Q下面介l的 JLDAP 是q这个的?/span>

我们需要看一?#8220; Java LDAP Overview ”里面的内宏V内容不是很多,但很实用?/span>

要在 java 中访?/span> ldap Q我们需要一?/span> api, 你可以在下面的网站上获得Q?/span>

http://developer.novell.com/wiki/index.php/LDAP_Classes_for_Java

在下在的文g里面有许多的例子Q在 novell 的网站上也有很多的例子。我׃讲了?/span> Try yourself ?/span>



junky 2007-06-06 15:45 发表评论
]]>
openldap学习W记(使用openldap-2.3.32)(详细)http://www.tkk7.com/junky/archive/2007/06/06/122361.htmljunkyjunkyWed, 06 Jun 2007 06:43:00 GMThttp://www.tkk7.com/junky/archive/2007/06/06/122361.htmlhttp://www.tkk7.com/junky/comments/122361.htmlhttp://www.tkk7.com/junky/archive/2007/06/06/122361.html#Feedback0http://www.tkk7.com/junky/comments/commentRss/122361.htmlhttp://www.tkk7.com/junky/services/trackbacks/122361.html本文pM者原创,转蝲请保留出处:http://marion.cublog.cn
其中理解可能也有不当之处Q欢q各位指正?br>
W一部分Qopenldap介绍

一、Directory Services(目录服务)能做什么?

    我们知道Q当局域网的规模变的越来越大时Qؓ了方便主机管理,我们使用DHCP来实现IP地址、以太网地址、主机名和拓扑结构等的集中管理和l一分配。同P如果一个局域网内有许多的其它资源时Q如打印机、共享文件夹{等Qؓ了方便的定位及查扑֮们,一U集中定位管理的方式或许是较好的选择QDNS和NIS都是用来实现cM理的方法?br>   
    对于局域网内的一个用hԌ工作{其它应用需要,我们必须凭帐L录主机、用帐号收发E-mailQ甚至ؓ了管理需要公司还需要维护一个电子号码簿来存储员工的姓名、地址、电话号码等信息。随着旉的增长,我们会ؓq些来多的帐号和密码弄的头晕脑胀。同Ӟ如果一个员工离开Q管理员׃得不遍所有的记录帐号信息的文件把职员工的信息删除。这些将是一个繁琐而效率低下的工作。那么,如果能将此些帐号信息{统一C个文件中q行理Q无疑会大大提高员工及管理员的工作效率。目录服务(LDAP是其实现的一U)正是Zq些应用实现的?br>
二、什么是LDAPQ?br>   
    LDAP是Lightweight Directory Access Protocol的羃写,֐思义Q它是指轻量U目录访问协议(q个主要是相对另一目录讉K协议X.500而言的;LDAP略去了x.500中许多不太常用的功能Q且以TCP/IP协议为基Q。目录服务和数据库很cMQ但又有着很大的不同之处。数据库设计为方便读写,但目录服务专门进行了M化的设计Q因此不太适合于经常有写操作的数据存储。同ӞLDAP只是一个协议,它没有涉及到如何存储q些信息Q因此还需要一个后端数据库lg来实现。这些后端可以是bdb(BerkeleyDB)、ldbm、shell和passwd{?br>
    LDAP目录以树状的层次l构来存储数据(q很cd于DNSQ,最层x部称?#8220;基准DN”QŞ?dc=mydomain,dc=org"或?o=mydomain.org"Q前一U方式更为灵zM是Windows AD中用的方式。在根目录的下面有很多的文g和目录,Z把这些大量的数据从逻辑上分开QLDAP像其它的目录服务协议一样用OUQOrganization UnitQ,可以用来表示公司内部机构Q如部门{,也可以用来表C备、h员等。同时OUq可以有子OUQ用来表C更为细致的分类?br>
    LDAP中每一条记录都有一个唯一的区别于其它记录的名字DNQDistinguished NameQ?其处?#8220;叶子”位置的部分称作RDNQ如dn:cn=tom,ou=animals,dc=mydomain,dc=org中tom即ؓRDNQRDN在一个OU中必L唯一的?br>
三、什么是LDIFQ?br>
    LDIF(LDAP Interchange Format)是指存储LDAP配置信息及目录内容的标准文本文g格式Q之所以用文本文件来格式来存储这些信息是Z方便d和修改,q也是其它大多数服务配置文g所采取的格式。LDIF文g常用来向目录导入或更改记录信息,q些信息需要按照LDAP中schema的格式进行组l,q会接受schema的检查,如果不符合其要求的格式将会出现报错信息。LDIF文g样例如下Q?br>
#LDIF file example
dn: dc=mydomain,dc=org
objectClass: domain
dc: mydomain

    其中Q以“#”号开头的为注释行Q第二行L行中Q冒号左边ؓ属性,双是属性的|q类同于~程中的变量及ؓ其所赋的|但属性可以被重复赋倹{?br>
四、objectClass

    LDAP中,一条记录必d含一个objectClass属性,且其需要赋予至一个倹{每一个值将用作一条LDAP记录q行数据存储的模板;模板中包含了一条记录中C必须被赋值的属性和一pd可选的属性。如上述LDIF文g中的记录所C,objectClass的gؓdomain?br>
    objectClass有着严格的等U之分,最层的类是top和alias。例如,organizationalPersonq个objectClass隶属于Person,而Person又是top的子cR?br>
    objectClass大致分ؓ三类Q结构型的(如:person和organizationUnitQ、辅助型的(如:extensibeObjectQ和抽象型的Q这cM能直接用)。官方定义的objectClass,如下所C:

alias
applicationEntity
dSA
applicationProcess
bootableDevice
certificationAuthority
certificationAuthority-V2
country
cRLDistributionPoint
dcObject
device
dmd
domain
domainNameForm
extensibleObject
groupOfNames
groupOfUniqueNames
ieee802Device
ipHost
ipNetwork
ipProtocol
ipService
locality
dcLocalityNameForm
nisMap
nisNetgroup
nisObject
oncRpc
organization
dcOrganizationNameForm
organizationalRole
organizationalUnit
dcOrganizationalUnitNameForm
person
organizationalPerson
inetOrgPerson
uidOrganizationalPersonNameForm
residentialPerson
posixAccount
posixGroup
shadowAccount
strongAuthenticationUser
uidObject
userSecurityInformation

五、Attribute介绍

    如上文所qͼAttributecd于编E语a中的变量Q它可以被赋|像是可以存放一个单一cd信息的容器。官方声明了许多常用的Attribute,如果其中没有你所需要的Q你可以自己定义Q但要避免重名。objectClass是一U特D的AttributeQ它包含其它用到的Attribute以及它自w。常见的Attribute如:givenName、l、objectClass、dc、ou、cn、c、mail、telephoneNumber、sn、uid{。分别介l如下:

c:国家Q?br>cn:common name,指一个对象的名字Q如果指人,需要用其全名Q?br>dc:domain Component,l常用来指一个域名的一部分Q如Qdc=mydomain,dc=org;
givenNameQ指一个h的名字,不能用来指姓或者middle nameQ?br>l:指一个地名,如一个城市或者其它地理区域的名字Q?br>mail:电子信箱地址
o:organizationName,指一个组l的名字;
objectClass:一个LDAP server要想启用必须能够识别每一个对象的AttributeQobjectClass Attribute正是用来描述一个对象应该具有的Attribute及可选Attribute。因此,每个objectClass“模板”的Attribute中必然含有一条objectClass AttributeQ我不知道用“自包?#8221;U呼q个不合适?br>ou:organizationalUnitName,指一个组l单元的名字?br>sn:surname,指一个h的姓;
telephoneNumber:电话LQ应该带有所在的国家的代码;
uid:userid,通常指一个h的登录名Q这个不同于Linuxpȝ中用LuidQ?

    如果可以q样cL的话Q我惻I我们不妨把objectClass理解为关pL据库的表Q而attribute则类同ؓ表中的字Dc而下面即可介l的schema或许可以cL作一个数据库Q但它的q个cL或许从逻辑上说更合适些?br>
六、什么是schema

        好了Q现在可以说说到底什么是schema了。LDAP中,schema用来指定一个目录中所包含的objects的类型(objectClassQ以及每一个objectClass中的各个必备QmandatoryQ和可选(optionalQ的属性(attributeQ。因此,Schema是一个数据模型,它被用来军_数据怎样被存储,被跟t的数据的是什么类型,存储在不同的Entry下的数据之间的关pR?/font>schema需要在主配|文件slapd.conf中指定,以用来决定本目录中用到的objectClass。管理员可以自己设计制定schemaQ一般包括属性定义(AttributeDefinitionQ、类定义QClassDefinitionQ以及语法定义(SyntaxDefinitionQ等部分?nbsp; 

    LDAP V3中在x.500标准的基上定义了一个包含了|络中大多常见对象的schemaQ这些对象包括国家、所在地、组l、h员、小l以及设备等。同ӞLDAP V3中可以很方便的从目录中提取出schemaQ它正是一条记录中关于属性的声明部分?br>
七、对象标识符QObject IdentifiersQ?br>
     对象标识W(OIDQ是被LDAP内部数据库引用的数字标识。Attribute的名字是设计为方便h们读取的Q但Z方便计算机的处理Q通常使用一l数字来标识q些对象Q这cd于SNMP中的MIB2。例如,当计机接收到dcq个AttributeӞ它会这个名字{换ؓ对应的OIDQ?.3.6.1.4.1.1466.115.121.1.26?br>

八、用LDAP做n份验?br>
    验正主要是用来确定一ơ会M客户端用hh的权利,即用来确立用戯否登录以及登录具有用哪些资源以及如何用资源的权限。验正过E中的修攏V查询等操作p证别来控制?br>
    objectClass中的person可以用来作linuxpȝ中用L入的w䆾验正Q此旉要指定userPassword属性的|x定用L入时使用的密码。密码可以用的加密方式有MD5、CRYPT、SHA、SSHA{。在LDAP V3中,验正客户端时可以使用的验正机制有匿名验正、简单验正、基于SSL/TLS的验正和ZSASL的验正等四种方式?br>
W二部分Q安装配|Openldap-2.3.32

    目前有许多种软g可以实现LDAPQ如Windows AD,Openldap{。我们要实现的是在RedHat9.0上安装Openldap来实现其应用?br>
    Z让openldap支持ssl/tls和saslQ我们这ơ的安装首先安装openssl0.98e和cyrus-sasl-2.0.22q两个Y件包?br>
一、安装openssl0.98e

1.1 下蝲相关软g包至/usr/local/src目录

http://www.openssl.org/source/openssl-0.9.8e.tar.gz

1.2 安装openssl

#cd /usr/local/src
#tar zxvf openssl-0.9.8e.tar.gz
#cd openssl-0.9.8e
#./config shared zlib
#make
#make test
#make install
mv /usr/bin/openssl /usr/bin/openssl.OFF
mv /usr/include/openssl /usr/include/openssl.OFF
ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/ssl/include/openssl /usr/include/openssl

1.3 配置库文件搜索\?br>
#echo "/usr/local/ssl/lib" >> /etc/ld.so.conf
#ldconfig -v

1.4 查看openssl的版本号Q以验正是否安装正确

#openssl version -a
OpenSSL 0.9.8e 17 Apr 2007
built on: Sat Mar 24 21:24:41 CST 2007
platform: linux-elf
options:  bn(64,32) md2(int) rc4(idx,int) des(ptr,risc1,16,long) idea(int) blowfish(idx)
compiler: gcc -fPIC -DOPENSSL_PIC -DZLIB -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall -DOPENSSL_BN_ASM_PART_WORDS -DOPENSSL_IA32_SSE2 -DSHA1_ASM -DMD5_ASM -DRMD160_ASM -DAES_ASM
OPENSSLDIR: "/usr/local/ssl"


二、安装cyrus-sasl-2.0.22

2.1 下蝲cyrus-sasl-2.1.22?usr/local/src
http://ftp.andrew.cmu.edu/pub/cyrus-mail/cyrus-sasl-2.1.22.tar.gz

2.2 ~译安装

#tar zxvf cyrus-sasl-2.1.22.tar.gz
#cd  cyrus-sasl-2.1.22
# ./configure --prefix=/usr/local/sasl2 --enable-login --with-openssl=/usr/local/ssl
#make
#make install

2.3配置库文件搜索\?br>
#echo "/usr/local/sasl2/lib" >> /etc/ld.so.conf
#echo "/usr/local/sasl2/lib/sasl2" >> /etc/ld.so.conf
#ldconfig -v

2.4 把Redhat9.0原有的sasl库文件改名或删除Qƈ相关符号链接指向新安装SASL的库文g

#cd /usr/lib
# mv libsasl2.a libsasl2.a.OFF
# mv libsasl2.la libsasl2.la.OFF
# mv libsasl2.so libsasl2.so.OFF
# mv libsasl2.so.2.0.10 libsasl2.so.2.0.10.OFF
# mv lIbsasl2.so.2 libsasl2.so.2.OFF

# ln -s /usr/local/sasl2/lib/* /usr/lib
# ln -s /usr/local/sasl2/lib/sasl2 /usr/lib/sasl2

#ln -s /usr/local/sasl2/lib/libsasl2.so.2.0.22 /usr/lib/libsasl2.so.2
#ln -s /usr/local/sasl2/lib/libsasl2.so /usr/lib/libsasl2.so

2.5 创徏q行旉要的目录q调试启?br>
#mkdir -pv /var/state/saslauthd      

# ./saslauthd -a pam shadow -d
saslauthd[3533] :main            : num_procs  : 5
saslauthd[3533] :main            : mech_option: NULL
saslauthd[3533] :main            : run_path   : /var/state/saslauthd
saslauthd[3533] :main            : auth_mech  : pam
saslauthd[3533] :ipc_init        : using accept lock file: /var/state/saslauthd/mux.accept
saslauthd[3533] :detach_tty      : master pid is: 0
saslauthd[3533] :ipc_init        : listening on socket: /var/state/saslauthd/mux
saslauthd[3533] :main            : using process model
saslauthd[3534] :get_accept_lock : acquired accept lock     Q此处?ctrl+c"退出)
saslauthd[3533] :have_baby       : forked child: 3534
saslauthd[3533] :have_baby       : forked child: 3535
saslauthd[3533] :have_baby       : forked child: 3536
saslauthd[3533] :have_baby       : forked child: 3537

2.6 启动q测试验?br>
#/usr/local/sasl2/sbin/saslauthd -a pam shadow

#/usr/local/sasl2/sbin/testsaslauthd -u root -p root的密?br>0: OK "Success."

三、安装BerkeleyDB

3.1 下蝲相关软g?usr/local/src

http://www.oracle.com/technology ... .5.20/db-targz.html

3.2 ~译安装

#tar zxvf db-4.5.20.tar.gz
#cd db-4.5.20/build_unix
#../dist/configure --prefix=/usr/local/BerkeleyDB
#make
#make install

四、安装openldap-2.3.32

4.1 下蝲相关软g?usr/local/src

http://www.openldap.org/software ... stable-20070110.tgz

4.2 ~译安装

#tar zxvf openldap-stable-20070110.tgz
#cd openldap-2.3.32
#env CPPFLAGS="-I/usr/local/BerkeleyDB/include -I/usr/local/sasl2/include" LDFLAGS="-L/usr/local/BerkeleyDB/lib -L/usr/local/sasl2/lib -L/usr/local/sasl2/lib/sasl2"  ./configure --prefix=/usr/local/openldap --sysconfdir=/etc/openldap --enable-passwd --enable-wrappers --disable-ipv6 --enable-spasswd --enable-crypt --enable-modules  --enable-accesslog=yes
#make depend
#make
#make test
#make install
#cp /usr/local/openldap/var/openldap-data/DB_CONFIG.example /usr/local/openldap/var/openldap-data/DB_CONFIG

4.3 试启动

# /usr/local/openldap/libexec/slapd -d 256
@(#) $OpenLDAP: slapd 2.3.32 (Apr 17 2007 00:44:16) $
        root@localhost.localdomain:/usr/local/src/openldap-2.3.32/servers/slapd
Expect poor performance for suffix dc=my-domain,dc=com.
slapd starting

4.4 启动及关闭服?br>
启动
#/usr/local/openldap/libexec/slapd

查看监听的端?br># netstat -tunlp |grep :389
tcp        0      0 0.0.0.0:389             0.0.0.0:*               LISTEN      10111/slapd

查看能否正常查询
# /usr/local/openldap/bin/ldapsearch -x -b '' -s base '(objectclass=*)' (此行为命令,以下为结?
# extended LDIF
#
# LDAPv3
# base <> with scope baseObject
# filter: (objectclass=*)
# requesting: ALL
#

#
dn:
objectClass: top
objectClass: OpenLDAProotDSE

# search result
search: 2
result: 0 Success

# numResponses: 2
# numEntries: 1


关闭
#kill -INT `cat /usr/local/openldap/var/run/slapd.pid`


五、主配置文gslapd.conf介绍

安全赯Qslapd.conf文g应该只让q行此进E的用户可读写。下面是安装完毕后的一个slapd.confCZ?br>
#
# See slapd.conf(5) for details on configuration options.
# This file should NOT be world readable.
#
include         /etc/openldap/openldap/schema/core.schema

# Define global ACLs to disable default read access.

# Do not enable referrals until AFTER you have a working directory
# service AND an understanding of referrals.
#referral       ldap://root.openldap.org

pidfile         /usr/local/openldap/var/run/slapd.pid
argsfile        /usr/local/openldap/var/run/slapd.args

# Load dynamic backend modules:
# modulepath    /usr/local/openldap/libexec/openldap
# moduleload    back_bdb.la
# moduleload    back_ldap.la
# moduleload    back_ldbm.la
# moduleload    back_passwd.la
# moduleload    back_shell.la

# Sample security restrictions
#       Require integrity protection (prevent hijacking)
#       Require 112-bit (3DES or better) encryption for updates
#       Require 63-bit encryption for simple bind
# security ssf=1 update_ssf=112 simple_bind=64

# Sample access control policy:
#       Root DSE: allow anyone to read it
#       Subschema (sub)entry DSE: allow anyone to read it
#       Other DSEs:
#               Allow self write access
#               Allow authenticated users read access
#               Allow anonymous users to authenticate
#       Directives needed to implement policy:
# access to dn.base="" by * read
# access to dn.base="cn=Subschema" by * read
# access to *
#       by self write
#       by users read
#       by anonymous auth
#
# if no access controls are present, the default policy
# allows anyone and everyone to read anything but restricts
# updates to rootdn.  (e.g., "access to * by * read")
#
# rootdn can always read and write EVERYTHING!

#############################################################
# BDB database definitions
#############################################################

database        bdb
suffix          "dc=my-domain,dc=org"
rootdn          "cn=Manager,dc=mydomain,dc=org"
# Cleartext passwords, especially for the rootdn, should
# be avoid.  See slappasswd(8) and slapd.conf(5) for details.
# Use of strong authentication encouraged.
rootpw          secret
# The database directory MUST exist prior to running slapd AND
# should only be accessible by the slapd and slap tools.
# Mode 700 reorgmended.
directory       /usr/local/openldap/var/openldap-data
# Indices to maintain

index   objectClass     eq

接下来我们对上述部分q行一些介l:

include         /etc/openldap/openldap/schema/core.schema

此句是用来将目录所用到的schema文g包含q来Qopenldap一般默认带有几个schemaQ在我们的配|文件安装目录下的schema目录中存放。本句中的core.schema是LDAP V3中必ȝQ它l出了LDAP V3中最基本的attribute和objects的定义。其它的q有Qcorba.schema、dyngroup.schema、java.schema  nis.schema、openldap.schema、cosine.schema、inetorgperson.schema、misc.schema、ppolicy.schema


pidfile         /usr/local/openldap/var/run/slapd.pid

此句用来定义slapdq程q行时的pid文gQ需要用绝对\径?br>
argsfile        /usr/local/openldap/var/run/slapd.args

此句用来定义包含当前正在q行的slapdq程所用到的命令行参数的文Ӟ需要用绝对\径?br>
# Load dynamic backend modules:
# modulepath    /usr/local/openldap/libexec/openldap
# moduleload    back_bdb.la
# moduleload    back_ldap.la
# moduleload    back_ldbm.la
# moduleload    back_passwd.la
# moduleload    back_shell.la

以上用来指定动态加载的后端模块?br>
# Sample security restrictions
#       Require integrity protection (prevent hijacking)
#       Require 112-bit (3DES or better) encryption for updates
#       Require 63-bit encryption for simple bind
# security ssf=1 update_ssf=112 simple_bind=64

以上是安全相关的声明语句。常用到的参数有五类Q除了Require和security外还有Allow、Disallow和password-hash{?br>Require参数用来使管理员指定讉K目录时必遵循的规则和条Ӟq种指定可以是全局的,也可以仅用来限制Ҏ个后端数据库的访问限制?br>security参数用来让管理员指定加强安全性的一般规则?br>
# Sample access control policy:
#       Root DSE: allow anyone to read it
#       Subschema (sub)entry DSE: allow anyone to read it
#       Other DSEs:
#               Allow self write access
#               Allow authenticated users read access
#               Allow anonymous users to authenticate
#       Directives needed to implement policy:
# access to dn.base="" by * read
# access to dn.base="cn=Subschema" by * read
# access to *
#       by self write
#       by users read
#       by anonymous auth
#
# if no access controls are present, the default policy
# allows anyone and everyone to read anything but restricts
# updates to rootdn.  (e.g., "access to * by * read")
#
# rootdn can always read and write EVERYTHING!

以上主要是用来定义访问控制列表?br>
#######################################################################
# BDB database definitions
#######################################################################

database        bdb

定义使用的后端数据存储方式。其后可以跟的值有bdb、ldbm、passwd、config、dnssrv、ldif、perl、hdb和shell{。bdb指用Berkley DB 4数据库?br>
suffix          "dc=my-domain,dc=org"

定义suffix,以上部分可以改作你的域名中相关的部分Q如"dc=example,dc=com"?br>
rootdn          "cn=Manager,dc=mydomain,dc=org"

定义此目录的񔽎理员帐Pcd于系l中的root。由于访问控制对此用h不生效的Q因此存在很大的安全隐患。徏议安装配|及调试完成以后U除此帐受?br>
rootpw          secret

定义񔽎理员帐L密码Q这里用的是明文存储(secretx其密码)的方式。这是极不安全的Q徏议用加密方式存储,可以使用的加密方式有QCRYPT、MD5、SMD5、SHA和SSHA。生加密密码散列的Ҏ是用slappasswd命oQ用-h选项指明加密时用的方式。示例如下:
# /usr/local/openldap/sbin/slappasswd -h {SSHA}
New password:
Re-enter new password:
{SSHA}k2H1GPM/95VfgsKg2jZv9hV+2GCH04hC


directory       /usr/local/openldap/var/openldap-data

q一句用来指定目录相x据的存放位置。此目录最好只能由q行slapdq程的用h有,推荐权限?00

index   objectClass     eq

此句用来指定slapd索引时用到的attributeQeq指烦引时的匹配规则。主要是用来优化查询的。常用到的匹配规则有QapproxQ模p匹?approximateQ、eqQ精匹配,equalityQ、presQ现值匹配,若某记录的此attribute没有值则不进行匹配,presenceQ和sub Q子串匹配,substringQ?br>


六、具体应用的实现Q徏立v始目录项Qƈ导入数据

6.1 先徏立一个创v始结Ҏ用的ldif文g

#vi init.ldif

输入以下内容Q可以根据自q需要修改)
dn: dc=mydomain,dc=org  #定义根结?br>objectClass: top
objectClass: domain
objectClass: organization
dc: mydomain
o: mydomain.org
description:  Mydomain.org ldap


dn: cn=Manager,dc=mydomain,dc=org    #定义目录理?br>objectClass: organizationalRole
cn: Manager
description: Directory Manager

dn: ou=people,dc=mydomain,dc=org  #定义一个OU
ou: people
objectClass: organizationalUnit

注意Qldif文g中,每一行中冒号后有一个空|行尾一定不能有I格。切?

6.2使用ȝimport命o导入到目录中,需要离U进行(要先关闭slapdq程Q?br>
#kill -INT `cat /usr/local/openldap/var/run/slapd.pid`
# /usr/local/openldap/sbin/slapadd -v -l ./init.ldif
bdb_db_open: Warning - No DB_CONFIG file found in directory /var/openldap/data-3: (2)
Expect poor performance for suffix dc=mydomain,dc=org.
added: "dc=mydomain,dc=org" (00000001)
added: "ou=people,dc=mydomain,dc=org" (00000002)

命o中:
-v选项表示启用verbose模式Q即输出执行中的具体信息Q?br>-l表示后面附加ldif文g?br>其它常用的选项q有:
-d  指定debug向日志文件输Z息,后面跟日志?br>-f  指定要读取的配置文g

6.3 启动服务q程

#/usr/local/openldap/libexec/slapd

6.4 建立要导入的具体信息记录的ldif文g

#vi users.ldif

dn: cn=Tom Black,ou=people,dc=mydomain,dc=org   定义人员1
cn: Tom Black
sn: Black
mail: tom@126.com
telephoneNumber: 371-6338-3522
objectClass: inetOrgPerson

dn: cn=Jerry Smith,ou=people,dc=mydomain,dc=org    定义人员2
cn: Jerry Smith
sn: Smith
mail: jerry@sina.com
telephoneNumber: 371-6338-3521
objectClass: inetOrgPerson

6.5 导入ldif文g

# /usr/local/openldap/bin/ldapadd -D "cn=Manager,dc=mydomain,dc=org" -W -x  -f users.ldif
Enter LDAP Password:
adding new entry "cn=Tom Black,ou=people,dc=mydomain,dc=org"

adding new entry "cn=Jerry Smith,ou=people,dc=mydomain,dc=org"

命o?
-D选项表示指定l定到LDAP的DNQ?br>-W表示提示用户输入密码Q?br>-x表示使用单n份验正方式,默认的是使用saslq行验正Q?br>-f用来指定ldif文g;

七、配|文件中的高U功能用方?br>
1. 开启日志功?br>
启用日志功能Q需要在~译时指?-enable-debug 选项Q默认是允许的。要打开slapd的日志功能,需要在slapd.conf中的全局配置D|加loglevel指oQƈ后跟一个十q制数字表示的日志别,如下所C:

# Added logging parameters
loglevel     256

其日志别如下所C:

-1        记录所有的信息
0        不记录debug
1        跟踪功能调用的信?br>2        包处理的debug信息
4        丰富的debug信息
8        q接理信息
16        包的收发信息
32        搜烦qo的处理过E?br>64        配置文g的处理过E?br>128        讉K控制列表处理q程
256        q接、操作及其结果的l计数据
512        向客Lq回的结果的l计信息
1024        与shell后端的通信信息
2048        昄记录条目的分析信?br>4096        数据库缓存处理信?br>8192        数据库烦?br>16384        从服务器数据同步资源消耗处理信?br>
若要记录所有的debug日志Q可以用LOG_LEVEL4 syslogdpȝ日志来记录,q需要在slapd.conf中添加如下语句实玎ͼ

local4.debug        /var/log/slapd.log

2. 为BDB后端数据库实例指定在内存中的~存I间大小

在如下句子后
DBDirectory:        /usr/local/openldap/var/openldap-data
后添加:
DBCachesize: 2000

3. 讉K控制列表:

3.1 语法

access to <what>[by <who> <access> <control>]+

其中,access to指示启用讉K控制Q上句大致可以理解ؓ:
access to <对什么目标进行控?gt;[by <作用于哪些访问?gt; <授予什么样的访问权?gt;<采取什么样的匹配控制动?gt;]+


3.2 剖析

3.2.1 控制目标<what>

q一域主要是实现对ACL应用对象的指定,对象可以是记录和属性。选择ACL目标记录的方法一般有两种QDN和filter,语法为:

<what> ::= * |
                [dn[.<basic-style>]=<regex> | dn.<scope-style>=<DN>]
                [filter=<ldapfilter>] [attrs=<attrlist>]
3.2.1.1 指定所有的记录

access to *

3.2.1.2 通过DN指定

语法如下Q?br>
to dn[.<basic-style>]=<regex>
<basic-style> ::= regex | exact
        
to dn.<scope-style>=<DN>
<scope-style> ::= base | one | subtree | children

W一U方法是使用正则表达?dn.regex)或精匹?dn.style)的方式来匚wW合条g的记录(q个好像不像惌的那么简单,实现h颇ؓ费脑{)Q例如:

access to dn="^.*,uid=([^,]+),ou=users,(.*)$"


W二U方法通过“区域”选择的方法进行目标记录的选取Q对以指定的DN开始的目录树区域进行目标记录匹配。匹配区域的方式共有四种Q?br>base                只匹配DN本n一条记?br>one                匚w以给定DN为父目录的所有记?br>subtree                匚w以给定DN为根目录的所有子树内的记?br>children        匚wl定DN下的所有记录,但应该不包括以DN直接命名的那条记?参见例子的解?

例如Q对?br>
0: dc=mydomain,dc=org
1: cn=root,dc=mydomain,dc=org
2: ou=users,dc=mydomain,dc=org
3: uid=samba,ou=users,dc=mydomain,dc=org
4: cn=Administator,uid=samba,ou=users,dc=mydomain,dc=org
5: uid=guest,ou=users,dc=mydomain,dc=org

规则 dn.base="ou=users,dc=mydomain,dc=org" 只会匚w记录2
规则 dn.one="ou=users,dc=mydomain,dc=org" 匚w记录3和记?Q记?是记?的子目录Q故不算在内
规则 dn.subtree="ou=users,dc=mydomain,dc=org" 匚w记录2???
规则 dn.children="ou=users,dc=mydomain,dc=org" 匚w记录3??,因ؓ记录0??都是以DN直接命名的,故不匚w

3.2.1.3 通过filter匚w记录

通过filter指定qo规则q行记录q虑Q语法如下:

access to filter=<ldap filter>

其中filter指定的ؓsearch的过滤规则,q类同于linuxpȝ中grep的匹配方式。如Q?br>
access to filter=(objectClass=sambaSamAccount)

也可以结合用DN和filterq行记录的匹配,例如Q?br>
access to dn.subtree="ou=users,dc=mydomain,dc=org" filter=(objectClass=posixAccount)

3.2.1.4 通过attrs选取匚w记录

语法:
attrs=<attribute list>

例如Q?br>access to attrs=uid,uidNumber,gidNumber

也可以结合用DN和attrsq行记录的匹配,例如Q?br>access to dn.subtree="ou=users,dc=mydomain,dc=org" attrs=uid

3.2.2 被用来授权的讉K?lt;who>的指?br>
指定被授权的用户范围的方法大致有以下几种Q?br>*                        所有的讉K者,包括匿名的用?br>anonymous                非认证的匿名用户
users                        认证的用?br>self                        目标记录的用戯w?br>dn[.<basic-style>]=<regex>        在指定目录内匚w正则表达式的用户
dn.<scope-style>=<DN>                指定DN内的用户

例如Q?br>by dn.subtree="ou=users,dc=domain,dc=org"="^samba*"

3.2.3 被授予的权限<access>

当选取好ACL作用的目标记录ƈ选取好用戯围后Q就该给q些用户授予他们应该得到的权限了。大致的权限(׃到高)有以下几c:
none        无权限,xl访?br>auth        讉KbindQ认证)讄的权限;前提是需要用h交一个DN形式的用户名q能通过认证
compare        比较属性的权限Q(例如Q对照查看某用户的telephoneNumber值是不是158 8888 8888Q?但ƈ不具有搜索的权限
search        利用q虑条gq行搜烦的权?但这q不一定具有可d搜烦l果的权?br>read        d搜烦l果的权?br>write        更改记录属性值的权限

可以在slapd.conf文g中通过defaultaccess指定默认的权限?如:
defaultaccess        search

3.2.4 采取什么样的匹配控制动?lt;control>

在进行记录的匚wӞ如果有多条规则存在,那么在第一ơ匹配生后是否q进行后l的匚w或采取其它的动作取决于此项的设|;控制方式共有以下三种Q?br>
stop                q个是默认|q表C在一ơ匹配生后不再进行下一个匹配,所有后l的匚w会停止?br>continue        无论匚w是否已经发生Ql进行直到所有的规则全部q行完匹配检?br>break                一个匹配发生后Q蟩出当前的子句q行后一个子句的?br>
3.2.5 一个例?br>
access to dn.chilren="ou=users,dc=mydomain,dc=org"
    attrs=userPassword  #指定“密码”属?br>    by self write       #用户自己可更?br>    by * auth           #所有访问者需要通过认证
    by dn.children="ou=admins,dc=mydomain,dc=org" write  #理员组的用户可更改

待箋……


junky 2007-06-06 14:43 发表评论
]]>
[LDAP][译]OpenLDAP理员指?仅前七章) (?http://www.tkk7.com/junky/archive/2007/06/06/122343.htmljunkyjunkyWed, 06 Jun 2007 05:04:00 GMThttp://www.tkk7.com/junky/archive/2007/06/06/122343.htmlhttp://www.tkk7.com/junky/comments/122343.htmlhttp://www.tkk7.com/junky/archive/2007/06/06/122343.html#Feedback1http://www.tkk7.com/junky/comments/commentRss/122343.htmlhttp://www.tkk7.com/junky/services/trackbacks/122343.html阅读全文

junky 2007-06-06 13:04 发表评论
]]>
q行OpenLdap(?http://www.tkk7.com/junky/archive/2007/06/06/122342.htmljunkyjunkyWed, 06 Jun 2007 05:02:00 GMThttp://www.tkk7.com/junky/archive/2007/06/06/122342.htmlhttp://www.tkk7.com/junky/comments/122342.htmlhttp://www.tkk7.com/junky/archive/2007/06/06/122342.html#Feedback0http://www.tkk7.com/junky/comments/commentRss/122342.htmlhttp://www.tkk7.com/junky/services/trackbacks/122342.html1?nbsp;安装OpenLdap

比如装在d:\openldap


2、了解ldap http://www.linuxaid.com.cn/engineer/brimmer/html/LDAP.htm
 

 

3?nbsp;修改slap.conf

假设域名为:netone.com

大概?/span>56?/span>

#######################################################################

 

 

# BDB database definitions只要更改下面两个地方可以了,注意suffix?/span>rootdn?/span>dc要相?/span>

 

 

#######################################################################

 

 

 

 

database bdb

#新的?/span>

 

 

suffix          "dc=netone,dc=com"  

#原来的?/span>        

 

 

#suffix           "dc=my-domain,dc=com"   

#新的?/span>   

 

 

rootdn            "cn=Manager,dc=netone,dc=com"

#原来的?/span>

 

 

#rootdn          "cn=Manager,dc=my-domain,dc=com"

 

 

4?nbsp;?/span>domain.ldif

 

 

dn:dc=netone,dc=com

 

 

objectclass:dcObject

 

 

objectclass:organization

 

 

o:companyinfo

 

 

dc:netone

 

 

保存在安装的目录?/span>,?/span> d:\openldap

 

 

5?nbsp;q行

命o?/span> 到达 d:\openldap

然后输入命oQ?/span>增加配置Q?/span>Q?/span>slapadd -f slapd.conf -l domain.ldif

 

 

接着输入命oQ启?/span>ldap服务Q:slapd -d 1

 

 

如果最后几行有 starting p明运行成功?/span>

 

 

 

 

6?span> 查看

 

 

可以通过jxplorerQ?/span>下蝲地址Q?/span>http://pegacat.com/jxplorer/Q来查看目录l构?/span>

 

 

q行jxplorer,点击左上角的Q类D接)图标Q配|?/span>ldap的连接参?/span>

 

 

W一二行可以不改?/span>

 

 

Base DN:输入我们的域名:dc=netone.com

 

 

Level为匿?/span>

 

 

按钮 OKQ如果能q接成功Q那么恭喜你?/span>

另外也可以用 LDAP Browser/Editor (下蝲l ) 来查看,

 

 

解压后运行:lbe.bat

 

 

然后q接ldap服务?/span>(刚运行时?/span>quickConnect,?/span>File->connect)

 

 

填写参数Q?/span>Host:localhost

 

 

               Port:386

 

 

               Version:3

 

 

               BaseDN:dc=netone,dc=com

 

 

最后按按钮啦。成功!

 

 

 

 

本文是参照:

 

 

http://www.cjsdn.net/post/view?bid=11&id=90353&sty=3&age=0&tpg=1&ppg=1#90353

 

 

http://www.cjsdn.net/post/view?bid=11&id=90367&sty=3&age=0&tpg=1&ppg=1#90367

 

 

http://www.ldapchina.com

 



junky 2007-06-06 13:02 发表评论
]]>
学习LDAP的过E??http://www.tkk7.com/junky/archive/2007/06/06/122339.htmljunkyjunkyWed, 06 Jun 2007 05:01:00 GMThttp://www.tkk7.com/junky/archive/2007/06/06/122339.htmlhttp://www.tkk7.com/junky/comments/122339.htmlhttp://www.tkk7.com/junky/archive/2007/06/06/122339.html#Feedback0http://www.tkk7.com/junky/comments/commentRss/122339.htmlhttp://www.tkk7.com/junky/services/trackbacks/122339.html   写这文章,是因为,最q学习了LDAP的相关知识,因ؓ整个学习q程都与|络有关Q大量的文献资料都是从网上下载下来的。现,我学习LDAP的过E简要列出来Q目的是想ؓ那些q没有接触和掌握LDAP的h来说Q能够节U大量的旉和精力?/p>

1?span style="FONT: 7pt 'Times New Roman'">  LDAP的英文的意思我是早接触,只是了解Qƈ不深入,所以,q次惛_了解一些,于是从网上下载了大量的资料,从理Z了解LDAP是怎么回事Q如什么是LDAPQ什么是X.500QX.500与LDAP是什么关p?X.500与X.509Q什么是DN{,大家在网上输入关键字LDAP可以搜烦到很多的相关的资料?/span>LDAP

2?span style="FONT: 7pt 'Times New Roman'">  光说不练不行Q还得找一找YӞ我所知道的,提供LDAP目录服务的Y件有IBM dominoQSUN 提供的YӞ以及开源的OPENLDAPQ而我手头没有安有LINUX操作pȝ的机器,所以,软g最好能在windows server 2003上运行。安装要单,配置最好也要简单。于是,我从|上下蝲了openldap for win32的安装包?/p>

3?span style="FONT: 7pt 'Times New Roman'">  安装q程很顺利,安装好后Q用netstat –an 查看QLDAP服务?89端口处于正常的侦听状态,说明服务正常启动了?/p>

4?span style="FONT: 7pt 'Times New Roman'">  Ҏ下蝲的文档,修改slapd.conf配置文gQ将MY-DOMAIN改ؓ自已讑֮的名Uͼ如ydzy。样例文件如下:

database bdb

suffix             "dc=ydzy,dc=com"

rootdn            "cn=Manager,dc=ydzy,dc=com"

# Cleartext passwords, especially for the rootdn, should

# be avoid. See slappasswd(8) and slapd.conf(5) for details.

# Use of strong authentication encouraged.

rootpw    secret

# The database directory MUST exist prior to running slapd AND

# should only be accessible by the slapd and slap tools.

# Mode 700 recommended.

directory ./data

# Indices to maintain

index       objectClass     eq

5?span style="FONT: 7pt 'Times New Roman'">  然后Q按照OPENLDAP快速帮助的说明Q自已制作了根DN的ydzy.ldif文g?/p>

dn: dc=ydzy,dc=com

objectclass: dcObject

objectclass: organization

o: Example Company

dc: ydzy

 

dn= cn=Manager,dc=ydzy,dc=com

objectclass: organizationalRole

cn: Manager

q里要说明一下,׃本h下蝲的LDAP文档Q绝大部分都是针对LINUX环境Q提供的d条目到LDAP目录服务器的命o是LINUX环境下的Q所以,照抄ӞL不对。在WINDOWS命o行状态,要用双引h括住一些信息。如上面的添加条目信息的命o为:

Ldapadd –x –D “cn=Manager,dc=ydzy,dc=com” –w secret –f ydzy.ldif

6?span style="FONT: 7pt 'Times New Roman'">  在设定了最基本的条目后Q我试着从VB工程中,用LDAP的ACTIVEX控g来连接LDAP服务器,无论在connect函数中怎么讑֮Q就是报协议错,为此Q花费了我不时间和_֊Q我是在VB6中,通过AXLDAP控gq接OPENLDAP服务器的。这当中Q最大的问题Q就是LDAP服务器的理员用户名和口令是什么。尽后来才知道Q不是连接LDAP服务器的用户名与口o不正,而是控g不支持我所安装的OPENLDAP服务器的版本所致?/p>

7?span style="FONT: 7pt 'Times New Roman'">  管QOEPNLDAP提供了命令行的ldapsearhc工具Q但对初学者来Ԍ仍然Q不形象直观Q于是,上网搜烦Q从http://www.ldapadministrator.com/下蝲了windows版的ldap客户端Y件。这真是个好东西Q下载下来,安装好后Q进行简单的讄Q那个OPENLDAP里面的内容就展现在我面前了。友情提醒一下,最好在下蝲OPENLDAP的时侯,׃载相应的客户端工Pq对于学习和理解LDAP的相关知识很有好处的Q本人就是通过q款软g才迅速解决了许多问题。例如,前面所说的用户?口o的问题,因在该Y件中Q要q接LDAP服务器,必须提供相应的用户名和口令,于是Q我p着填入相应的用户名和口令,l于明白Qslapd.conf文g中的rootdn后面的一长串是理员的用户名,而rootpw后的明文secret是理员的密码Q所以,象命令中?D “cn=Manager,dc=ydzy,dc=com” –w secret 是通常的用户名和口令的格式?/p>

8?span style="FONT: 7pt 'Times New Roman'">  前面Q我们刚学会d根DN的方法,在实际应用中Q需要添加各U各L信息到LDAP中,而要d信息Q必L握写作LDIF文g的方法,具体的LDIF的格式要求,从下载的文档Q大家可以看到。我Ҏ一文档的介绍Q将公司员工的邮件地址存入LDAP服务器,以便于在OUTLOOK{工具中可以查询。于是,我编写了以下格式的文Ӟ

dn: cn=lxj,dc=ydzy,dc=com

objectclass: inetorgPerson

cn: lxj

cn: luoxiaojun

sn: luo

mail: lxj@192.1.3.211

 

dn: cn=lxr,dc=ydzy,dc=com

objectclass: inetorgPerson

cn: lxr

cn: lixinyue

sn: li

mail: lxr@192.1.3.211

是向目录服务器Q添加两个条目?/p>

然后Q就用ldapadd 命o向目录服务器加,始终报语法错误,q是怎么回事呢?左看右看Q这Ӟ我通过LDAP客户端YӞ查看其中的模式,发现没有inetorgpersonq个模式Q于是我惛_Q是否,应在slapd.conf中将相关的模式文件包含进来,于是打开slapd.conf文gQ发玎ͼ默认的配|文件中Q只有一个core.schema包含了进来,而在openldap的安装文件夹下,可以看到schema文g夹,于是Q将相应的inetorgperson模式文gd到slapd.conf文g中。重启openldap服务器,再运行添加条目的命oQ成功,通过LDAP客户端工P可以看到Q几条信息已l成功地d到LDAP服务器中?/p>

9?span style="FONT: 7pt 'Times New Roman'">  我在|上Q也看到一些文章讲LDAP应用面变H的问题Q其实,我们通过PKIQ通过LDAPQ我们发玎ͼ国外Q似乎在q求一U基架构Q即公共Q标准,安全。LDAP中能存储的在关系l数据库基本上都可以存储Q但关系数据库无法做CZU公p施,MQ便于实施,所以,从追求标准化来看QLDAP来是信息基础构gQ就象家里用的灯泡一P而不是应用越来越H,相反Q会得到很广的应用。比如,微Y的activedirectoryzd目录Q不是一个例证吗Q?/p>

10?span style="FONT: 7pt 'Times New Roman'">              通过X.500或LDAP的条目DN可以和X.509数字证书l定在一P便于用户的查询。这U应用是较好的一U组合?/p>

11?span style="FONT: 7pt 'Times New Roman'">              服务器提供了M服务器的复制功能Q确保了LDAP的稳定性和可靠性,实现h也很Ҏ?/span>LDAP



junky 2007-06-06 13:01 发表评论
]]>
openldap for win32 安装E序制作分析 相关参考资料与研究(?http://www.tkk7.com/junky/archive/2007/06/06/122336.htmljunkyjunkyWed, 06 Jun 2007 04:58:00 GMThttp://www.tkk7.com/junky/archive/2007/06/06/122336.htmlhttp://www.tkk7.com/junky/comments/122336.htmlhttp://www.tkk7.com/junky/archive/2007/06/06/122336.html#Feedback0http://www.tkk7.com/junky/comments/commentRss/122336.htmlhttp://www.tkk7.com/junky/services/trackbacks/122336.htmlopenldap for win32

(http://lucas.bergmans.us/hacks/openldap/)q是主要来源资料文档?/p>

Download

Binary Distributions

http://download.bergmans.us/openldap/

Developer Documentation/Patches

http://download.bergmans.us/openldap/devel/Q老外的编译开发资源包Q?/p>

http://www.jrsoftware.org/Q安装程序Inno Setup下蝲地址Q?/p>

http://www.sleepycat.com/Qopenldap使用的Berkeley DBQ?/p>

Please note that if you have a server in production using aSleepycat/Berkeley DB backend (which is the default), then you willnot want to cut over to an OpenLDAP build that uses a different BDBversion until you have thoroughly tested the change.  If you havea build from me that doesn't specify a bdb version in the filename,then the version used was 4.2.52.Also, there has been talk on openldap-software that bdb-4.3 stillhas some non-trivial bugs, so proceed at your own risk.  -- Lucas Bergman <lucas@bergmans.us>     2004-12-10

 

Getting Started

I'm working on installation documentation at the same time as a better release. In the meantime, there is some documentation on getting my current port working under Windows in French and English (endless thanks to Mickaël Guessant).

FAQ

  1. Where can I download the OpenLDAP software for Windows?

    Use the “download” link on the left side of this page.

  2. I've downloaded the software and installed it, and everything seems okay. Now what do I do?

    Start with Mickaël Guessant's getting started documentation (in French and English), and then start learning something.

  3. Will you help me use OpenLDAP with my mail client?

    That, and other questions that have nothing to do with the running OpenLDAP on Windows in particular, should be directed to the official OpenLDAP forums. The answers you get will be better, and the time you save will be your own.

  4. How can I build OpenLDAP for myself?

    Right now, the scripts I use to build the software are stored in a subdirectory of the download site. However, I've moved things to CVS, so be prepared to deal with that.

  5. I see your build uses the MinGW build of the GNU toolchain. How can I build with the Microsoft toolchain (e.g., Microsoft Visual C++ .NET 2008 Enterprise .COM Visual .ORG Special Edition Service Pack 9)?

    I don't care. I have no interest in using proprietary tools when free ones will produce the exact same result.

    But it's for my job! My company has a policy that we use only Microsoft tools! My boss won't let me use your hippie compiler.

    Since it's for your job, I'm sure your company won't mind paying me a consulting fee to get the thing working with the proprietary toolchain of your choice.

  6. Do you have the SQL backend? I'd like to have OpenLDAP use an RDBMS as a storage medium.

    We don't yet, since it was only relatively recently that we've gotten modern versions of the server working in an easily installed package. This is a common request, and I swear we're working on it.

  7. If my question isn't here, can I email you?

    Talk to the list.


上面主要是第六条需要注意一下数据库的用问题?/p>

http://www.mingw.org/Q这个暂时不清楚是做什么用的)

http://www.gnu.org/home.cn.htmlQ开源自pY件协议公U)

 

下面是一位兄弟自q译的windows版本q程?/p>

Windhue’s homepage

 

 

OpenLDAP for win32 ~译q程举例

 

 

 

 

 

 

环境: WinXP Pro sp2; Visual C++ 6?

目标Q编?span> openldap ?debug 版本?

 

 

1. Berkeley DB

 

 

- 得到 db-4.1.24.tar.gz。可在网上google一下,例如Q目前点?q里 可以下蝲?/span>

 更新版本的,应该也没有问题,但是我没有测试?

- 解压到某个文件夹。例?F:\db-4.1.24?

- 阅读 F:/db-4.1.24/docs/ref/build_win/intro.html

- F:\db-4.1.24\build_win32\Berkeley_DB.dsw Q用VC打开它?

- ?#8220;build all - Win32 Debug”讄为活动工E?

- rebuild all

 生成的文件位?F:\db-4.1.24\build_win32\Debug?

 F:\db-4.1.24\build_win32\Debug_Static。我需要的是前者?

- libdb41d.lib拯到VC的lib目录?

- libdb41d.dll拯到系l目录?

- copy db.h to {VC's include path}

 

 

2. Cyrus SASL

 

 

- 解压 cyrus-sasl-2.1.15.rar ?F:\cyrus-sasl-2.1.15

- 阅读 file:///F:/cyrus-sasl-2.1.15/doc/windows.html

- cd F:\cyrus-sasl-2.1.15\lib

- {VC's path}\VC98\Bin\vcvars32.bat

 

 

 nmake /f NTMakefile CFG=Debug

 

 

- libsasl.lib 拯?span> VC ?span> lib 目录?span>

 

 

 libsasl.dll 拯到系l目录?span>

 

 

- copy sasl.h       {VC's include path}\sasl.h

 copy prop.h       {VC's include path}\prop.h

 copy saslplug.h   {VC's include path}\sasl\saslplug.h

 copy md5global.h {VC's include path}\sasl\md5global.h

 copy md5.h        {VC's include path}\sasl\md5.h

 copy hmac-md5.h   {VC's include path}\hmac-md5.h

 

 

3. hs_regex

 

 

- 下蝲 hs_regex.exe 自解压文件?

 把文件拷贝到相应的目录。hs_regex.dll regex.h hs_regex.lib

 

 

4Qopenssl

 

 

- 我用的是openssl-0.9.7b。在windows下的~译q程不赘q。参?a >http://www.openssl.org/ http://openssl.cn/ ?/span>

 

 

5. openldap

 

 

- 解压 openldap-*.*.**.rar。点?q里 下蝲?

- 打开build/main.dsw

- ?#8220;build - Win32 Debug”讄为活动工E。看一?readme.txt?

- build“build - Win32 Debug”?nbsp;

- slapd讄为活动工E。运?slapd 。参?slapd 目下的 readme.txt?

- ldapadd之后Q可能重启一下slapd才能看到变化?

 

 

6. LDAP Browser/Editor

 

 

 一个java的ldap客户端浏览器。点?q里 下蝲?

 

 

注意 Q?span> slurpd׃包含一些linux的符Pq没UL到win32。主要是一些与文g操作相关的函数和宏定义。移植应该不会十分困难。至于openldap在win32q_上的性能问题Q这里不做讨论?

 

 

 

 

windhue@sina.com

2004-11-23

 

 

/* END */



junky 2007-06-06 12:58 发表评论
]]>
有关LDAP协议的整??http://www.tkk7.com/junky/archive/2007/06/04/121754.htmljunkyjunkyMon, 04 Jun 2007 01:36:00 GMThttp://www.tkk7.com/junky/archive/2007/06/04/121754.htmlhttp://www.tkk7.com/junky/comments/121754.htmlhttp://www.tkk7.com/junky/archive/2007/06/04/121754.html#Feedback0http://www.tkk7.com/junky/comments/commentRss/121754.htmlhttp://www.tkk7.com/junky/services/trackbacks/121754.htmlLDAP的英文全U是Lightweight Directory Access Protocol,卌量目录讉K协议.我们知道,Z对计机|络的用和理涉及了各U庞杂的资源,信息.Z提高性能,便于使用,有效理分布式应用的服务,资源,用户及别的对象信?q些信息需要清?一致地l织h.Zq样的需?描述各种用户,应用,文g,打印机和其它可从|络讉K的资源的信息被集中到一个特D的数据库中,q种数据库被UCؓ目录.目录存放对象的公开或非公开的信?q些信息以某U顺序组l?描述了每个对象的l节.电话?图书馆藏书卡片目录就是常见的目录. LDAP是基于X.500标准?讉K X.500 目录需要某U协?例如:目录讉K协议 (DAP).然?DAP 需要大量的pȝ资源和支持机制来处理复杂的协?LDAP 仅通过使用原始 X.500目录存取协议 (DAP) 的功能子集而减了所需的系l资源消?而且可以Ҏ需要定?此外,与X.500不同,LDAP支持TCP/IP,q对讉KInternet是必ȝ. Z能对LDAP协议q行更好的理?我们需要对以下概念有初步的认识:目录:Directory,存放对象的信?q些信息以某U顺序组l?详细描述每个对象.目录信息?DIT,Directory Information Tree,目录条目的集合构成了目录信息?条目:Entry,目录信息树中的一个结?是一个对象信息的集合,是目录信息中最基本的单?包含该对象的一pd属?属?Attribute,属性描q对象的特征.一个属性由属性类?type)和一个或多个属性?values)构成.相对标识?RDN,Relative Distinguished Name,条目的名?唯一标识?DN,Distinguished Name,在一个目录信息树中唯一标识一个条目的名字. LDAPQ轻量目录讉K协议QLightweight Directory Access Protocol)是实现提供被UCؓ目录服务的信息服务?目录服务是一U特D的数据库系l,其专门针对读取,览和搜索操作进行了特定的优化。目录一般用来包含描 q性的Q基于属性的信息q支持精l复杂的qo能力。目录一般不支持通用数据库针对大量更新操作操作需要的 复杂的事务管理或回卷{略。而目录服务的更新则一般都非常单。这U目录可以存储包括个Z息、web铄?jpeg囑փ{各U信息。ؓ了访问存储在目录中的信息Q就需要用运行在TCP/IP之上的访问协议—LDAP?

LDAP目录中的信息是是按照树型l构l织Q具体信息存储在条目(entry)的数据结构中。条目相当于关系数据库中 表的记录Q条目是h区别名DNQDistinguished NameQ的属性(AttributeQ,DN是用来引用条目的QDN相当?关系数据库表中的关键字(Primary KeyQ。属性由cdQTypeQ和一个或多个|ValuesQ组成,相当于关pL 据库中的字段QFieldQ由字段名和数据cdl成Q只是ؓ了方便检索的需要,LDAP中的Type可以有多个ValueQ?而不是关pL据库中ؓ降低数据的冗余性要求实现的各个域必L不相关的。LDAP中条目的l织一般按照地理位|?和组l关p进行组l,非常的直观。LDAP把数据存攑֜文g中,为提高效率可以用基于烦引的文g数据库,而不 是关pL据库。类型的一个例子就是mailQ其值将是一个电子邮件地址?

WebLogic的内|的LDAP Server支持IETF LDAP为LDAPv3制定的控制访问模型。下面这个片断将讲述在内|的LDAP Server中怎样实现控制讉K。可以通过~辑讉K控制文g来将q些规则直接应用到目录的入口。WebLogic中的讉K控制文g是acls.prop。在Server的lib中可以找到这个文件。这个文件的所有访问控制规则都被注释掉了,如果x改这些规则,你要手工更改q个文g。注意:WebLogic Server内置的LDAP Server在默认的情况下只允许Admin帐号讉KQWebLogic Server的security providers只用Admin帐号讉K内置的LDAP Server。如果你不想使用外部的LDAP Brower讉KWebLogic Server的内|的LDAP ServerQ或者你只想使用Admin帐号讉K内置的LDAP ServerQ你不需要编辑acls.prop文gQ访问控制文ӞThe Access Control FileQ?/p>

讉K控制文gQacls.propQ包含内|的LDAP Server的整个目录的完整的访问控制列表(ACLQ。这个文件中的每一行都包含一个访问控制规则。一个访问控制规则由下面接个部分l成Q?讉K控制位置(Access Control Location) 每个讉K控制规则都应用于LDAP目录中的一个给定的位置。这个位|通常是一个区别命名(DNQ,但有一个例外,q就是[root]Q如果访问控制规则应用到整个目录Q则只需要指定位|ؓ[root]可以了Q?如果被访问或更改的入口的位置与访问控制规则指定的位置不相{,或在讉K控制规则指定的位|的下Q则q个讉K控制规则不会被执行?/p>

讉K控制范围QAccess Control ScopeQ?讉K控制范围?U: Entry-一个Entry范围的访问控制列表只在下面的情况下被执行Q?LDAP目录的入口的DN与访问控制规则指定的位置相同。这L规则对于包含了比q行和副入口更敏感信息的单独入口非常有用?Subtree-意味着讉K控制规则指定的位|及子树都可以适用q条规则?如果Entry与Subtree在访问控制规则中有冲H,则Entry要优先于Subtree?/p>

讉K权限QAccess RightsQ?讉K权限应用于整个对象或对象的属性,?个|grantQ准许)或denyQ拒l)。访问权限指定了LDAP操作的类型?许可(grant或deny)

应用规则的属?attribute)

允许或拒l访问的主题(subject) 在weblogic可以~写E序来访问LDAP.上手时可以选择JXplorer工具?1.LDAP Server及LDAP BrowserQ?对于WLS LDAP为理解v来简单,L限制的方法是修改bea\weblogic81\server\lib\acls.prop文g后。修Ҏ法:在该文g最后添加以下几行。[root]|entry#grant:s,r,o,w,c,m#[all]#public[root]|subtree#grant:s,r,o,w,c,m#[all]#public:[root]|subtree#grant:a,d,e,i,n,b,t#[entry]#public:cn=schema|entry#grant:s,r,o,w,c,m#[all]#public:cn=schema|entry#grant:a,d,e,i,n,b,t#[entry]#public:注意Q该文g中这些行之间Q以及其他行之间不能有空行,否则启动WLS会报错的。修改好之后可以启动WLS了,启动后进入Console里修改Ldap Server的密码。密码修改完后需要再重新启动一ơWLS?/p>

LDAP刚上手的时候没有方便的工具会很费劲。我看了CSDN?#8220;兔八?#8221;的文章,用JXplorerQ感觉很不错。想看这文章,到CSDN上搜一?#8220;兔八?#8221;Q系列中No.12是关于JXplorer的配|和使用。我的连接参数如下:Host:localhost//Ҏ实际修改Port:7001Protocol:LDAP v3Base DN:dc=ldapdomain//Ҏ实际修改Level:User PasswordUser DN:cn=AdminPassword:weblogic//Ҏ实际修改.~程操作LDAP Server?下面四个JAVAҎQ分别用于初始化Q查询,dQ删除,修改Q关闭连接?记得每次都需要先大概q接Q操作,然后关闭q接。和使用数据库差不多?首先是需要用到的头文Ӟimport java.util.Hashtable;import java.util.Enumeration;import javax.naming.Context;import javax.naming.NamingException;import javax.naming.directory.DirContext;import javax.naming.directory.InitialDirContext;import javax.naming.directory.SearchControls ;import javax.naming.NamingEnumeration;import javax.naming.directory.SearchResult;import javax.naming.directory.Attributes ;import javax.naming.directory.Attribute;import javax.naming.directory.BasicAttributes;import javax.naming.directory.BasicAttribute;import javax.naming.directory.ModificationItem;import java.lang.reflect.Method;import java.io.BufferedReader;import java.io.InputStreamReader;

然后是一个类域,用于保存上下文: DirContext ctx = null; 然后是初始化Q?public void init(){ String account="Admin";//操作LDAP的帐戗默认就是Admin?String password="weblogic";//帐户Admin的密码?String root="dc=ldapdomain"; //所操作的WLS域。也是LDAP的根节点的DC Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");//必须q样写,无论用什么LDAP服务器?env.put(Context.PROVIDER_URL, "ldap://localhost:7001/" root);//LDAP服务器的地址:端口。对WLS端口是7001 env.put(Context.SECURITY_AUTHENTICATION, "none");//授权界别Q可以有三种授权U别Q但是如果设为另外两U都无法dQ我也不知道为啥Q但是只能设成这个?none"?env.put(Context.SECURITY_PRINCIPAL, "cn=" account "," root);//载入登陆帐户和登录密?env.put(Context.SECURITY_CREDENTIALS, password); try{ ctx = new InitialDirContext(env);//初始化上下文 System.out.println("认证成功");//q里可以Ҏ异常抛出?}catch(javax.naming.AuthenticationException e){ System.out.println("认证p|"); }catch(Exception e){ System.out.println("认证出错Q? e); } }

查询操作Q?public void search(){//我只能按照某些属性查找节点,偶还不会怎么查找一个目录或按照更复杂的正则式查扄定节点/目录 try{ SearchControls constraints = new SearchControls(); constraints.setSearchScope(SearchControls.SUBTREE_SCOPE); System.out.print("what would you want to search:"); BufferedReader bd=new BufferedReader(new InputStreamReader(System.in)); String s=bd.readLine(); NamingEnumeration en = ctx.search("", "uid=" s, constraints); //要查询的UID。如果是*则可以查到所有UID的节?if(en == null){ System.out.println("Have no NamingEnumeration."); } if(!en.hasMoreElements()){ System.out.println("Have no element."); } while (en != null && en.hasMoreElements()){//可以查出多个元素 Object obj = en.nextElement(); if(obj instanceof SearchResult){ SearchResult si = (SearchResult) obj; System.out.println("\tname: " si.getName()); Attributes attrs = si.getAttributes(); if (attrs == null){ System.out.println("\tNo attributes"); }else{ for (NamingEnumeration ae = attrs.getAll(); ae.hasMoreElements();){//获得该节点的所有属?Attribute attr = (Attribute) ae.next();//下一属?String attrId = attr.getID();//获得该属性的属性名 for (Enumeration vals = attr.getAll();vals.hasMoreElements();){//获得一个属性中的所有属性?System.out.print("\t\t" attrId ": "); Object o = vals.nextElement();//下一属性?if(o instanceof byte[]) System.out.println(new String((byte[])o)); else System.out.println(o); } } } } else{ System.out.println(obj); } System.out.println(); } }catch(Exception e){ System.out.println("Exception in search():" e); } } d操作Q?public void add(){ try{ String newUserName = "stella"; BasicAttributes attrs = new BasicAttributes(); BasicAttribute objclassSet = new BasicAttribute("objectclass"); objclassSet.add("person"); objclassSet.add("top"); objclassSet.add("organizationalPerson");

objclassSet.add("inetOrgPerson"); objclassSet.add("wlsUser"); attrs.put(objclassSet); attrs.put("sn", newUserName); attrs.put("uid", newUserName); attrs.put("cn", newUserName); ctx.createSubcontext("uid=" newUserName ",ou=people,ou=myrealm", attrs); //d一个节点,我还不会d目录 }catch(Exception e){ System.out.println("Exception in add():" e); } }

修改操作Q?public void edit(){ try{ String account = "stella";//修改以前旧的?String sn = "stella sn";//修改以后新的?ModificationItem modificationItem[] = new ModificationItem[1]; modificationItem[0] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, new BasicAttribute("sn", sn));//所修改的属?ctx.modifyAttributes("uid=" account, modificationItem); //执行修改操作 }catch(Exception e){ System.out.println("Exception in edit():" e); } }

删除节点操作Q?public void delete(){ try{ String uid = "stella"; ctx.destroySubcontext("uid=" uid); //按照UID删除某个节点。我q不会删除一个目录?}catch(Exception e){ System.out.println("Exception in edit():" e); } }

关闭q接Q?public void close(){ if(ctx != null) { try { ctx.close(); } catch (NamingException e) { System.out.println("NamingException in close():" e); } } }我对LDAP的理解:它是用于对资源的理和服务的讉K协议Q在Weblogicq_上的JNDIQ包含EJB和DataSource)都是提供它来提供的。正是JNDI的服务和RMIl合Ş成J2EEq_上分布式的应用,因此说到底层Q还是LDAP协议的支持?/p>

部分资料参考:http://www.tkk7.com/kapok/archive/2005/05/05/4034.html

http://www.blogdriver.com/goblinize/250559.html




junky 2007-06-04 09:36 发表评论
]]>
վ֩ģ壺 һëƬ޶| www߹ۿ| ˵Ӱ| ɫWWWƷƵ| ޾ƷһۺϾƷ| Ƶһ߹ۿ| ŷ޹Ʒ㽶| һëƬһֱӹۿ| þþþAV | ɫse01Ƶ| 91vavava| Ƭ߹ۿѴȫӰ | 123| þòþüӰԺ| ɫվwwwþþ| ŮƵ| ޹ŮƷþþ| һëƬ߲| һ˿wwwƵ| ޹aƷ| ĻƵ߹ۿ| ޴ɫwwwվ| 99þ޾Ʒһ| ɫɫwww| Ƶ69½| һһëƬ| av乾| 91㽹߹ۿ| ĻþþƷ| ޹ƷۺϾþ| 99߹ۿƵ| smһ| ŷAۺһ| 18ֹվ| ޾Ʒŷ߹ۿ| ޳AVƬ߹ۿww| aëƬƵ| caopornѹ| 337pձŷ޴| ѹһػƾþ| 鶹һƷһAVһ |