aboutsummaryrefslogblamecommitdiffstats
path: root/lib/eldap/doc/src/eldap.xml
blob: b68115cd8283778c7e284196328f59c45ad0b41b (plain) (tree)
1
2
3
4
5
6
7
                                       




                                     
                                        





























                                                                                             
                                    











                                                                                               
                                                 



















                                                                                           
                                                                                                                                               




                                                                                                        


                                                                                                  












                                                   
                                                                   
                                                       





                                                                            
                                                       






                                                                                                    

                                                                                                                                                                               




                                                                                                                                                                                                                                             
                  
                                                                          
                 


                                                             



                                                                                                    


             


























































































                                                                                   





































                                                                                                                   











                                                                                                


                                                                                                    

























                                                                                                  



                                                                                              





























                                                                                  
                                                      



                                                                   
                                                         


























































                                                                                     









                                                                                                                                                                                                                                                                                                                                                     



























                                                                                                 
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE erlref SYSTEM "erlref.dtd">

<erlref>
  <header>
    <copyright>
      <year>2012</year><year>2013</year>
      <holder>Ericsson AB. All Rights Reserved.</holder>
    </copyright>
    <legalnotice>
      The contents of this file are subject to the Erlang Public License,
      Version 1.1, (the "License"); you may not use this file except in
      compliance with the License. You should have received a copy of the
      Erlang Public License along with this software. If not, it can be
      retrieved online at http://www.erlang.org/.

      Software distributed under the License is distributed on an "AS IS"
      basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
      the License for the specific language governing rights and limitations
      under the License.

    </legalnotice>

    <title>eldap</title>
    <prepared>Peter H&ouml;gfeldt</prepared>
    <docno></docno>
    <date>2000-06-20</date>
    <rev>B</rev>
  </header>
  <module>eldap</module>
  <modulesummary>Eldap Functions</modulesummary>
  <description>
    <p>This module provides a client api to the Lightweight Directory Access Protocol (LDAP).
    </p>
    <p>References:</p>
    <list type="bulleted">
      <item> <p>RFC 4510 - RFC 4519</p> </item>
      <item> <p>RFC 2830</p> </item>
    </list>
    <p>The above publications can be found at <url href="http://www.ietf.org">IETF</url>.
    </p>
    <p><em>Types</em></p>
    <pre>
handle()    Connection handle
attribute() {Type = string(), Values=[string()]}
modify_op() See mod_add/2, mod_delete/2, mod_replace/2
scope()     See baseObject/0, singleLevel/0, wholeSubtree/0
dereference() See neverDerefAliases/0, derefInSearching/0, derefFindingBaseObj/0, derefAlways/0
filter()    See present/1, substrings/2,
                equalityMatch/2, greaterOrEqual/2, lessOrEqual/2,
                approxMatch/2, extensibleMatch/2,
                'and'/1, 'or'/1, 'not'/1.
    </pre>
    <p></p>
  </description>
  <funcs>
    <func>
      <name>open([Host]) -> {ok, Handle} | {error, Reason}</name>
      <fsummary>Open a connection to an LDAP server.</fsummary>
      <type>
	<v>Handle = handle()</v>
      </type>
      <desc>
        <p>Setup a connection to an LDAP server, the <c>HOST</c>'s are tried in order. </p>
      </desc>
    </func>
    <func>
      <name>open([Host], [Option]) -> {ok, Handle} | {error, Reason}</name>
      <fsummary>Open a connection to an LDAP server.</fsummary>
      <type>
	<v>Handle = handle()</v>
	<v>Option = {port, integer()} | {log, function()} | {timeout, integer()} | {ssl, boolean()} | {sslopts, list()} | {tcpopts, list()}</v>
      </type>
      <desc>
        <p>Setup a connection to an LDAP server, the <c>HOST</c>'s are tried in order.</p>
	<p>The log function takes three arguments, <c>fun(Level, FormatString, [FormatArg]) end</c>.</p>
	<p>Timeout set the maximum time in milliseconds that each server request may take.</p>
	<p>All TCP socket options are accepted except 
	  <c>active</c>, <c>binary</c>, <c>deliver</c>, <c>list</c>, <c>mode</c> and <c>packet</c>
	</p>
      </desc>
    </func>
    <func>
      <name>close(Handle) -> ok</name>
      <fsummary>Shutdown the connection.</fsummary>
      <type>
	<v>Handle = handle()</v>
      </type>
      <desc>
        <p>Shutdown the connection.</p>
      </desc>
    </func>
    <func>
      <name>start_tls(Handle, Options) -> ok | {error,Error}</name>
      <fsummary>Upgrade a connection to TLS.</fsummary>
      <desc>
        <p>Same as start_tls(Handle, Options, infinity)</p>
      </desc>
    </func>
    <func>
      <name>start_tls(Handle, Options, Timeout) -> ok | {error,Error}</name>
      <fsummary>Upgrade a connection to TLS.</fsummary>
      <type>
	<v>Handle = handle()</v>
	<v>Options = ssl:ssl_options()</v>
	<v>Timeout = inifinity | positive_integer()</v>
      </type>
      <desc>
        <p>Upgrade the connection associated with <c>Handle</c> to a tls connection if possible.</p>
	<p>The upgrade is done in two phases: first the server is asked for permission to upgrade. Second, if the request is acknowledged, the upgrade to tls is performed.</p>
	<p>Error responses from phase one will not affect the current encryption state of the connection. Those responses are:</p>
	<taglist>
	  <tag><c>tls_already_started</c></tag>
	  <item>The connection is already encrypted.  The connection is not affected.</item>
	  <tag><c>{response,ResponseFromServer}</c></tag>
	  <item>The upgrade was refused by the LDAP server.  The <c>ResponseFromServer</c> is an atom delivered byt the LDAP server explained in section 2.3 of rfc 2830. The connection is not affected, so it is still un-encrypted.</item>
	</taglist>
	<p>Errors in the second phase will however end the connection:</p>
	<taglist>
	  <tag><c>Error</c></tag>
	  <item>Any error responded from ssl:connect/3</item>
	</taglist>
	<p>The <c>Timeout</c> parameter is for the actual tls upgrade (phase 2) while the timeout in
	<seealso marker="#open/2">erl_tar:open/2</seealso> is used for the initial negotiation about
	upgrade (phase 1).
	</p>
      </desc>
    </func>
    <func>
      <name>simple_bind(Handle, Dn, Password) -> ok | {error, Reason}</name>
      <fsummary>Authenticate the connection.</fsummary>
      <type>
	<v>Handle = handle()</v>
        <v>Dn = string()</v>
        <v>Password = string()</v>
      </type>
      <desc>
        <p>Authenticate the connection using simple authentication.</p>
      </desc>
    </func>
    <func>
      <name>add(Handle, Dn, [Attribute]) -> ok | {error, Reason}</name>
      <fsummary>Add an entry.</fsummary>
      <type>
	<v>Handle = handle()</v>
        <v>Dn = string()</v>
	<v>Attribute = attribute()</v>
      </type>
      <desc>
	<p> Add an entry. The entry must not exist.</p>
	<pre>
  add(Handle,
      "cn=Bill Valentine, ou=people, o=Example Org, dc=example, dc=com",
       [{"objectclass", ["person"]},
        {"cn", ["Bill Valentine"]},
        {"sn", ["Valentine"]},
        {"telephoneNumber", ["545 555 00"]}]
     )
	</pre>
      </desc>
    </func>
    <func>
      <name>delete(Handle, Dn) -> ok | {error, Reason}</name>
      <fsummary>Delete an entry.</fsummary>
      <type>
        <v>Dn = string()</v>
      </type>
      <desc>
	<p> Delete an entry.</p>
	<pre>
  delete(Handle, "cn=Bill Valentine, ou=people, o=Example Org, dc=example, dc=com")
	</pre>
      </desc>
    </func>

    <func>
      <name>mod_add(Type, [Value]) -> modify_op()</name>
      <fsummary>Create a modification operation.</fsummary>
      <type>
        <v>Type = string()</v>
        <v>Value = string()</v>
      </type>
      <desc> <p> Create an add modification operation.</p> </desc>
    </func>
    <func>
      <name>mod_delete(Type, [Value]) -> modify_op()</name>
      <fsummary>Create a modification operation.</fsummary>
      <type>
        <v>Type = string()</v>
        <v>Value = string()</v>
      </type>
      <desc> <p> Create a delete modification operation.</p> </desc>
    </func>
    <func>
      <name>mod_replace(Type, [Value]) -> modify_op()</name>
      <fsummary>Create a modification operation.</fsummary>
      <type>
        <v>Type = string()</v>
        <v>Value = string()</v>
      </type>
      <desc> <p> Create a replace modification operation.</p> </desc>
    </func>

    <func>
      <name>modify(Handle, Dn, [ModifyOp]) -> ok | {error, Reason}</name>
      <fsummary>Modify an entry.</fsummary>
      <type>
        <v>Dn = string()</v>
        <v>ModifyOp = modify_op()</v>
      </type>
      <desc>
	<p> Modify an entry.</p>
	<pre>
  modify(Handle, "cn=Bill Valentine, ou=people, o=Example Org, dc=example, dc=com",
         [eldap:mod_replace("telephoneNumber", ["555 555 00"]),
	  eldap:mod_add("description", ["LDAP Hacker"]) ])
	</pre>
      </desc>
    </func>
    <func>
      <name>modify_password(Handle, Dn, NewPasswd) -> ok | {ok, GenPasswd} | {error, Reason}</name>
      <fsummary>Modify the password of a user.</fsummary>
      <type>
        <v>Dn = string()</v>
        <v>NewPasswd = string()</v>
      </type>
      <desc>
	<p>Modify the password of a user. See <seealso marker="#modify_password/4">modify_password/4</seealso>.</p>
      </desc>
    </func>
    <func>
      <name>modify_password(Handle, Dn, NewPasswd, OldPasswd) -> ok | {ok, GenPasswd} | {error, Reason}</name>
      <fsummary>Modify the password of a user.</fsummary>
      <type>
        <v>Dn = string()</v>
        <v>NewPasswd = string()</v>
        <v>OldPasswd = string()</v>
        <v>GenPasswd = string()</v>
      </type>
      <desc>
	<p>Modify the password of a user.</p>
        <list type="bulleted">
          <item>
            <p><c>Dn</c>. The user to modify. Should be "" if the
            modify request is for the user of the LDAP session.</p>
          </item>
          <item>
            <p><c>NewPasswd</c>. The new password to set. Should be ""
            if the server is to generate the password. In this case,
            the result will be <c>{ok, GenPasswd}</c>.</p>
          </item>
          <item>
            <p><c>OldPasswd</c>. Sometimes required by server policy
            for a user to change their password. If not required, use
            <seealso marker="#modify_password/3">modify_password/3</seealso>.</p>
          </item>
        </list>
      </desc>
    </func>
    <func>
      <name>modify_dn(Handle, Dn, NewRDN, DeleteOldRDN, NewSupDN) -> ok | {error, Reason}</name>
      <fsummary>Modify the DN of an entry.</fsummary>
      <type>
        <v>Dn = string()</v>
        <v>NewRDN = string()</v>
        <v>DeleteOldRDN = boolean()</v>
        <v>NewSupDN = string()</v>
      </type>
      <desc>
	<p> Modify the DN of an entry. <c>DeleteOldRDN</c> indicates
	whether the current RDN should be removed from the attribute list after the after operation.
	<c>NewSupDN</c> is the new parent that the RDN shall be moved to.  If the old parent should
	remain as parent, <c>NewSupDN</c> shall be "".</p>
	<pre>
  modify_dn(Handle, "cn=Bill Valentine, ou=people, o=Example Org, dc=example, dc=com ",
            "cn=Bill Jr Valentine", true, "")
	</pre>
      </desc>
    </func>
    <func>
      <name>search(Handle, SearchOptions) -> {ok, #eldap_search_result{}} | {error, Reason}</name>
      <fsummary>Search the Directory</fsummary>
      <type>
        <v>SearchOptions = #eldap_search{} | [SearchOption]</v>
        <v>SearchOption = {base, string()} | {filter, filter()} | {scope, scope()}
	| {attributes, [string()]} | {deref, dereference()} |
	| {types_only, boolean()} | {timeout, integer()}
	</v>
      </type>
      <desc>
	<p>Search the directory with the supplied the SearchOptions.
	The base and filter options must be supplied.
	Default values: scope is <c>wholeSubtree()</c>, deref is <c>derefAlways()</c>,
	types_only is <c>false</c> and timeout is <c>0</c> (meaning infinity).
	</p>
	<pre>
  Filter = eldap:substrings("cn", [{any,"V"}]),
  search(Handle, [{base, "dc=example, dc=com"}, {filter, Filter}, {attributes, ["cn"]}]),
	</pre>
	<p>The <c>timeout</c> option in the <c>SearchOptions</c> is for the ldap server, while
	the timeout in <seealso marker="#open/2">erl_tar:open/2</seealso> is used for each
	individual request in the search operation.
	</p>
      </desc>
    </func>

    <func>
      <name>baseObject() -> scope()</name>
      <fsummary>Create search scope.</fsummary>
      <desc> <p> Search baseobject only.</p> </desc>
    </func>
    <func>
      <name>singleLevel() -> scope()</name>
      <fsummary>Create search scope.</fsummary>
      <desc> <p> Search the specified level only, i.e. do not recurse.</p> </desc>
    </func>
    <func>
      <name>wholeSubtree() -> scope()</name>
      <fsummary>Create search scope.</fsummary>
      <desc> <p> Search the entire subtree.</p> </desc>
    </func>

    <func>
      <name>neverDerefAliases() -> dereference()</name>
      <fsummary>Create search option.</fsummary>
      <desc> <p>Never derefrence aliases, treat aliases as entries.</p> </desc>
    </func>
    <func>
      <name>derefAlways() -> dereference()</name>
      <fsummary>Create search option.</fsummary>
      <desc> <p>Always derefrence aliases.</p> </desc>
    </func>
    <func>
      <name>derefInSearching() -> dereference()</name>
      <fsummary>Create search option.</fsummary>
      <desc> <p>Derefrence aliases only when searching.</p> </desc>
    </func>
    <func>
      <name>derefFindingBaseObj() -> dereference()</name>
      <fsummary>Create search option.</fsummary>
      <desc> <p>Derefrence aliases only in finding the base.</p> </desc>
    </func>

    <func>
      <name>present(Type) -> filter()</name>
      <fsummary>Create search filter option.</fsummary>
      <type>
	<v>Type = string()</v>
      </type>
      <desc> <p>Create a filter which filters on attribute type presence.</p> </desc>
    </func>
    <func>
      <name>substrings(Type, [SubString]) -> filter()</name>
      <fsummary>Create search filter option.</fsummary>
      <type>
	<v>Type = string()</v>
	<v>SubString = {StringPart, string()}</v>
	<v>StringPart = initial | any | final</v>
      </type>
      <desc> <p>Create a filter which filters on substrings.</p> </desc>
    </func>
    <func>
      <name>equalityMatch(Type, Value) -> filter()</name>
      <fsummary>Create search filter option.</fsummary>
      <type>
	<v>Type = string()</v>
	<v>Value = string()</v>
      </type>
      <desc> <p>Create a equality filter.</p> </desc>
    </func>
    <func>
      <name>greaterOrEqual(Type, Value) -> filter()</name>
      <fsummary>Create search filter option.</fsummary>
      <type>
	<v>Type = string()</v>
	<v>Value = string()</v>
      </type>
      <desc> <p>Create a greater or equal filter.</p> </desc>
    </func>
    <func>
      <name>lessOrEqual(Type, Value) -> filter()</name>
      <fsummary>Create search filter option.</fsummary>
      <type>
	<v>Type = string()</v>
	<v>Value = string()</v>
      </type>
      <desc> <p>Create a less or equal filter.</p> </desc>
    </func>
    <func>
      <name>approxMatch(Type, Value) -> filter()</name>
      <fsummary>Create search filter option.</fsummary>
      <type>
	<v>Type = string()</v>
	<v>Value = string()</v>
      </type>
      <desc> <p>Create a approximation match filter.</p> </desc>
    </func>
    <func>
      <name>extensibleMatch(MatchValue, OptionalAttrs) -> filter()</name>
      <fsummary>Create search filter option.</fsummary>
      <type>
	<v>MatchValue = string()</v>
	<v>OptionalAttrs = [Attr]</v>
	<v>Attr = {matchingRule,string()} | {type,string()} | {dnAttributes,boolean()}</v>
      </type>
      <desc> <p>Creates an extensible match filter. For example, <c>eldap:extensibleMatch("Bar",[{type,"sn"},{matchingRule,"caseExactMatch"}]))</c> creates a filter which performs a <c>caseExactMatch</c> on the attribute <c>sn</c> and matches with the value <c>"Bar"</c>. The default value of <c>dnAttributes</c> is <c>false</c>.</p> </desc>
    </func>
    <func>
      <name>'and'([Filter]) -> filter()</name>
      <fsummary>Create search filter option.</fsummary>
      <type>
	<v>Filter = filter()</v>
      </type>
      <desc> <p>Creates a filter where all <c>Filter</c> must be true.</p> </desc>
    </func>
    <func>
      <name>'or'([Filter]) -> filter()</name>
      <fsummary>Create search filter option.</fsummary>
      <type>
	<v>Filter = filter()</v>
      </type>
      <desc> <p>Create a filter where at least one of the <c>Filter</c> must be true.</p> </desc>
    </func>
    <func>
      <name>'not'(Filter) -> filter()</name>
      <fsummary>Create search filter option.</fsummary>
      <type>
	<v>Filter = filter()</v>
      </type>
      <desc> <p>Negate a filter.</p> </desc>
    </func>

  </funcs>

</erlref>