You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by bu...@apache.org on 2012/10/02 16:07:57 UTC

svn commit: r833748 - in /websites/staging/directory/trunk/content: ./ api/five-minutes-tutorial.html css/common.css

Author: buildbot
Date: Tue Oct  2 14:07:56 2012
New Revision: 833748

Log:
Staging update by buildbot for directory

Added:
    websites/staging/directory/trunk/content/api/five-minutes-tutorial.html
Modified:
    websites/staging/directory/trunk/content/   (props changed)
    websites/staging/directory/trunk/content/css/common.css

Propchange: websites/staging/directory/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Tue Oct  2 14:07:56 2012
@@ -1 +1 @@
-1392919
+1392920

Added: websites/staging/directory/trunk/content/api/five-minutes-tutorial.html
==============================================================================
--- websites/staging/directory/trunk/content/api/five-minutes-tutorial.html (added)
+++ websites/staging/directory/trunk/content/api/five-minutes-tutorial.html Tue Oct  2 14:07:56 2012
@@ -0,0 +1,189 @@
+<!DOCTYPE html>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+<html>
+	<head>
+		<title>Five Minutes Tutorial &mdash; Apache Directory</title>
+		
+	    <link href="./../css/common.css" rel="stylesheet" type="text/css">
+	    <link href="./../css/brown.css" rel="stylesheet" type="text/css">
+    
+	</head>
+	<body>
+	    <div id="container">
+            <div id="header">
+                <div id="subProjectsNavBar">
+                    <a href="./../">
+                        
+                        Apache Directory Project
+                        
+                    </a>
+                    &nbsp;|&nbsp;
+                    <a href="./../apacheds">
+                        
+                        ApacheDS
+                        
+                    </a>
+                    &nbsp;|&nbsp;
+                    <a href="./../studio">
+                        
+                        Apache Directory Studio
+                        
+                    </a>
+                    &nbsp;|&nbsp;
+                    <a href="./../api">
+                        
+                        <STRONG>Apache LDAP API</STRONG>
+                        
+                    </a>
+                </div><!-- subProjectsNavBar -->
+            </div><!-- header -->
+            <div id="content">
+                <div id="leftColumn">
+                    
+<div id="navigation">
+    
+    <h5>Latest Downloads</h5>
+    <ul>
+	    <li><a href="./../api/downloads.html">Version 1.0.0-M11</a>&nbsp;&nbsp;<IMG src="./../images/new_badge.gif" alt="" style="margin-bottom:-3px;" border="0"></li>
+    </ul>
+    <h5>Getting Started</h5>
+    <ul>
+        <li><a href="./../api/vision.html">Vision</a></li>
+        <li><a href="./../api/java-api.html">Java API</a></li>
+        <li><a href="./../api/groovy-ldap.html">Groovy API</a></li>
+    </ul>
+    <h5>Documentation</h5>
+    <ul>
+	    <li><a href="./../api/five-minutes-tutorial.html">Five minutes tutorial</a></li>
+	    <li><a href="./../api/user-guide.html">User Guide</a></li>
+        <li><a href="./../api/gen-docs/latest/apidocs/">JavaDocs</a></li>
+        <li><a href="./../api/gen-docs/latest/">Generated Reports</a></li>
+        <li><a href="./../api/developer-guide.html">Developer Guide</a></li>
+    </ul>
+    
+    
+    <h5>Community</h5>
+    <ul>
+        <li><a href="./../contribute.html">How to Contribute</a></li>
+        <li><a href="./../team.html">Team</a></li>
+        <li><a href="./../original-project-proposal.html">Original Project Proposal</a></li>
+    </ul>
+    <h5>About Apache</h5>
+    <ul>
+        <li><a href="http://www.apache.org/">Apache</a></li>
+        <li><a href="http://www.apache.org/licenses/">License</a></li>
+        <li><a href="http://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li>
+        <li><a href="http://www.apache.org/foundation/thanks.html">Thanks</a></li>
+        <li><a href="http://www.apache.org/security/">Security</a></li>
+    </ul>
+    
+</div><!-- navigation -->
+
+                </div><!-- leftColumn -->
+                <div id="rightColumn">
+
+<h1 id="five-minutes-tutorial">Five Minutes Tutorial</h1>
+<h2 id="introduction">Introduction</h2>
+<blockquote>
+<p><em>Warning</em>: This is a very preliminary tutorial, the user must be informed that the current implementation will evolve a <strong>lot</strong> in the near future. So will the tutorial, hopefully...</p>
+</blockquote>
+<p>This new API has been created in order to offer a better API than what we currently use, namely JNDI or older API like LdapSDK or jldap. It benefits from some improvements brought by <strong>ApacheDS</strong> and <strong>OpenDS</strong>.</p>
+<p>This 5-minutes tutorial will present the way to use this API when working with a LDAP server.</p>
+<h2 id="base-principles">Base principles</h2>
+<p>LDAP is a connected protocol, so you need to create a connection in order to send request and receive response from a Ldap server. This is the main point : you have to create a connection first.</p>
+<p>Each operation can have one or more responses, and produce exceptions when something went wrong.</p>
+<p>The API is schema ware, ie the manipulated objects will be controlled on the client side, assuming you have brought back the schema from the server, or by using a default schema configuration</p>
+<h2 id="connection">Connection</h2>
+<p>In order to create a connection, you first have to provide the name of the server, and the port to use. Those parameters will be defaulted to <strong>localHost</strong> and <strong>389</strong> if nothing is defined. </p>
+<h3 id="opening-a-connection">Opening a connection</h3>
+<p>Here is an example :</p>
+<div class="codehilite"><pre><span class="n">LdapConnection</span> <span class="n">connection</span> <span class="o">=</span> <span class="k">new</span> <span class="n">LdapConnection</span><span class="o">(</span> <span class="s">&quot;localhost&quot;</span><span class="o">,</span> <span class="mi">389</span> <span class="o">);</span>
+</pre></div>
+
+
+<p>It's important to note that the connection has nothing to do with being bound, and this is a major difference with JNDI, where you create some context and provide the principalDN. A Connection is just a channel opened with the server, here.</p>
+<p>Another important thing to understand is that the connection is not explicitly opened. In fact, the <strong>bind</strong> operation will open the connection.</p>
+<h3 id="secure-connection">Secure connection</h3>
+<blockquote>
+<p>TODO</p>
+</blockquote>
+<h2 id="bind-operation">Bind operation</h2>
+<p>Now that the connection has been created, you can call the <strong>bind()</strong> method. This will create a identified connection between a client and the server. The <strong>bind</strong> operation has nothing to do with the <strong>JNDI</strong> bind, as no entry will be created.</p>
+<h3 id="anonymous-bind">Anonymous bind</h3>
+<p>You can bind using no identifier, and in this case, you'll create an anonymous LDAP session. This is done this way :</p>
+<div class="codehilite"><pre><span class="n">connection</span><span class="o">.</span><span class="na">bind</span><span class="o">();</span>
+</pre></div>
+
+
+<h3 id="simple-bind">Simple bind</h3>
+<p>The most common bind uses an identifier and a password. The identifier must be a <em>DN</em>, and the password can be encrypted. Here is an example of a bind operation :</p>
+<div class="codehilite"><pre><span class="c1">// Don&#39;t do that ! Password in clear text = danger !</span>
+<span class="n">connection</span><span class="o">.</span><span class="na">bind</span><span class="o">(</span> <span class="s">&quot;ou=example, dc=com&quot;</span><span class="o">,</span> <span class="s">&quot;secret&quot;</span> <span class="o">);</span>
+
+<span class="c1">// The password is encrypted, but it does not protect against a MITM attack</span>
+<span class="n">connection</span><span class="o">.</span><span class="na">bind</span><span class="o">(</span> <span class="s">&quot;ou=example, dc=com&quot;</span><span class="o">,</span> <span class="s">&quot;{crypt}wSiewPyxdEC2c&quot;</span> <span class="o">);</span>
+</pre></div>
+
+
+<h2 id="search-operation">Search operation</h2>
+<p>We have tried to make it easy to search information in a LDAP server, as this is the most frequently used operation.</p>
+<p>Many parameters can be used in a search. The most commonly used are :
+<em> The base DN
+</em> The filter
+<em> The scope
+</em> The returning attributes list</p>
+<h3 id="simple-search-operation">Simple search operation</h3>
+<p>Here is a simple search, done using only those four parameters :</p>
+<div class="codehilite"><pre><span class="n">Cursor</span><span class="o">&lt;</span><span class="n">SearchResponse</span><span class="o">&gt;</span> <span class="n">cursor</span> <span class="o">=</span> <span class="n">connection</span><span class="o">.</span><span class="na">search</span><span class="o">(</span> <span class="s">&quot;ou=system&quot;</span><span class="o">,</span> <span class="s">&quot;(objectclass=*)&quot;</span><span class="o">,</span> <span class="n">SearchScope</span><span class="o">.</span><span class="na">ONELEVEL</span><span class="o">,</span> <span class="s">&quot;*&quot;</span> <span class="o">);</span>
+
+<span class="k">while</span> <span class="o">(</span> <span class="n">cursor</span><span class="o">.</span><span class="na">next</span><span class="o">()</span> <span class="o">)</span>
+<span class="o">{</span>
+    <span class="n">SearchResponse</span> <span class="n">response</span> <span class="o">=</span> <span class="n">cursor</span><span class="o">.</span><span class="na">get</span><span class="o">();</span>
+
+    <span class="c1">// Process the response</span>
+    <span class="o">...</span>
+<span class="o">}</span>
+</pre></div>
+
+
+<p>Here, we call the search operation, and we get back a cursor. Reading search result from the cursor is done with the <strong>get()</strong> method, moving forward uses the <strong>next()</strong> method.</p>
+<h2 id="unbinding">Unbinding</h2>
+<p>When you are done with the operation, you can unbind. This is done by calling the <strong>unbind()</strong> method, this way :</p>
+<div class="codehilite"><pre><span class="n">connection</span><span class="o">.</span><span class="na">unbind</span><span class="o">();</span>
+</pre></div>
+
+
+<h2 id="closing-the-connection">Closing the connection</h2>
+<p>Once you are done with the connection, don't forget to close it. It's done by calling the <strong>close()</strong> method :</p>
+<div class="codehilite"><pre><span class="n">connection</span><span class="o">.</span><span class="na">close</span><span class="o">();</span>
+</pre></div>
+
+
+<p>If you explicitly call the <strong>unbind()</strong> method, the connection will also be closed, and in this case, you wont have to close it explicitly.</p>
+<h2 id="conclusion">Conclusion</h2>
+<p>This very limited presentation was written to give users a quick insight about how to use the <strong>API</strong>. In order to get some further information, please check the <strong><a href="user-guide.html">User Guide</a></strong></p>
+
+                </div><!-- rightColumn -->
+                <div id="endContent"></div>
+            </div><!-- content -->
+            <div id="footer">&copy; 2003-2012, <a href="http://www.apache.org">The Apache Software Foundation</a> - <a href="privacy-policy.html">Privacy Policy</a><br />
+                Apache Directory, ApacheDS, Apache Directory Server, Apache Directory Studio, Apache LDAP API, Apache Triplesec, Triplesec, Apache, the Apache feather logo, and the Apache Directory project logos are trademarks of The Apache Software Foundation.
+            </div>
+        </div><!-- container -->
+    </body>
+</html>
\ No newline at end of file

Modified: websites/staging/directory/trunk/content/css/common.css
==============================================================================
--- websites/staging/directory/trunk/content/css/common.css (original)
+++ websites/staging/directory/trunk/content/css/common.css Tue Oct  2 14:07:56 2012
@@ -533,4 +533,68 @@ th 
 .download td
 {
     padding: 0;
-}
\ No newline at end of file
+}
+
+
+.codehilite .hll { background-color: #ffffcc }
+.codehilite  { background: #f0f0f0; }
+.codehilite .c { color: #60a0b0; font-style: italic } /* Comment */
+.codehilite .err { border: 1px solid #FF0000 } /* Error */
+.codehilite .k { color: #007020; font-weight: bold } /* Keyword */
+.codehilite .o { color: #666666 } /* Operator */
+.codehilite .cm { color: #60a0b0; font-style: italic } /* Comment.Multiline */
+.codehilite .cp { color: #007020 } /* Comment.Preproc */
+.codehilite .c1 { color: #60a0b0; font-style: italic } /* Comment.Single */
+.codehilite .cs { color: #60a0b0; background-color: #fff0f0 } /* Comment.Special */
+.codehilite .gd { color: #A00000 } /* Generic.Deleted */
+.codehilite .ge { font-style: italic } /* Generic.Emph */
+.codehilite .gr { color: #FF0000 } /* Generic.Error */
+.codehilite .gh { color: #000080; font-weight: bold } /* Generic.Heading */
+.codehilite .gi { color: #00A000 } /* Generic.Inserted */
+.codehilite .go { color: #808080 } /* Generic.Output */
+.codehilite .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */
+.codehilite .gs { font-weight: bold } /* Generic.Strong */
+.codehilite .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
+.codehilite .gt { color: #0040D0 } /* Generic.Traceback */
+.codehilite .kc { color: #007020; font-weight: bold } /* Keyword.Constant */
+.codehilite .kd { color: #007020; font-weight: bold } /* Keyword.Declaration */
+.codehilite .kn { color: #007020; font-weight: bold } /* Keyword.Namespace */
+.codehilite .kp { color: #007020 } /* Keyword.Pseudo */
+.codehilite .kr { color: #007020; font-weight: bold } /* Keyword.Reserved */
+.codehilite .kt { color: #902000 } /* Keyword.Type */
+.codehilite .m { color: #40a070 } /* Literal.Number */
+.codehilite .s { color: #4070a0 } /* Literal.String */
+.codehilite .na { color: #4070a0 } /* Name.Attribute */
+.codehilite .nb { color: #007020 } /* Name.Builtin */
+.codehilite .nc { color: #0e84b5; font-weight: bold } /* Name.Class */
+.codehilite .no { color: #60add5 } /* Name.Constant */
+.codehilite .nd { color: #555555; font-weight: bold } /* Name.Decorator */
+.codehilite .ni { color: #d55537; font-weight: bold } /* Name.Entity */
+.codehilite .ne { color: #007020 } /* Name.Exception */
+.codehilite .nf { color: #06287e } /* Name.Function */
+.codehilite .nl { color: #002070; font-weight: bold } /* Name.Label */
+.codehilite .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */
+.codehilite .nt { color: #062873; font-weight: bold } /* Name.Tag */
+.codehilite .nv { color: #bb60d5 } /* Name.Variable */
+.codehilite .ow { color: #007020; font-weight: bold } /* Operator.Word */
+.codehilite .w { color: #bbbbbb } /* Text.Whitespace */
+.codehilite .mf { color: #40a070 } /* Literal.Number.Float */
+.codehilite .mh { color: #40a070 } /* Literal.Number.Hex */
+.codehilite .mi { color: #40a070 } /* Literal.Number.Integer */
+.codehilite .mo { color: #40a070 } /* Literal.Number.Oct */
+.codehilite .sb { color: #4070a0 } /* Literal.String.Backtick */
+.codehilite .sc { color: #4070a0 } /* Literal.String.Char */
+.codehilite .sd { color: #4070a0; font-style: italic } /* Literal.String.Doc */
+.codehilite .s2 { color: #4070a0 } /* Literal.String.Double */
+.codehilite .se { color: #4070a0; font-weight: bold } /* Literal.String.Escape */
+.codehilite .sh { color: #4070a0 } /* Literal.String.Heredoc */
+.codehilite .si { color: #70a0d0; font-style: italic } /* Literal.String.Interpol */
+.codehilite .sx { color: #c65d09 } /* Literal.String.Other */
+.codehilite .sr { color: #235388 } /* Literal.String.Regex */
+.codehilite .s1 { color: #4070a0 } /* Literal.String.Single */
+.codehilite .ss { color: #517918 } /* Literal.String.Symbol */
+.codehilite .bp { color: #007020 } /* Name.Builtin.Pseudo */
+.codehilite .vc { color: #bb60d5 } /* Name.Variable.Class */
+.codehilite .vg { color: #bb60d5 } /* Name.Variable.Global */
+.codehilite .vi { color: #bb60d5 } /* Name.Variable.Instance */
+.codehilite .il { color: #40a070 } /* Literal.Number.Integer.Long */
\ No newline at end of file