Your IP : 216.73.217.64
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>How To Install and Configure an LDAP Proxy-Cache Server — ownCloud 10.0.1 Server Administration Manual 10.0.1 documentation</title>
<link rel="stylesheet" href="../_static/" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../_static/main.min.css" type="text/css" />
<link rel="stylesheet" href="../_static/styles.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '10.0.1',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<script type="text/javascript" src="../_static/js/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="../_static/js/jquery-fix.js"></script>
<script type="text/javascript" src="../_static/bootstrap-3.1.0/js/bootstrap.min.js"></script>
<script type="text/javascript" src="../_static/bootstrap-sphinx.js"></script>
<link rel="top" title="ownCloud 10.0.1 Server Administration Manual 10.0.1 documentation" href="../contents.html" />
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1'>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="theme-color" content="#1d2d44">
</head>
<body role="document">
<div class="wrap container not-front">
<div class="content row">
<main class="main">
<div class="row page-content-header">
<div class="col-md-5 col-md-offset-7">
<form class="headersearch" style="margin-bottom:-3px;" action="../search.html" method="get">
<input type="text" value="" name="q" id="q" class="form-control" />
<button class="btn btn-default" type="submit" id="searchsubmit">Search</button>
</form>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="sidebar">
<div class="menu-support-container">
<ul id="menu-support" class="menu">
<ul>
<li><a href="../contents.html">Table of Contents</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../index.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="../release_notes.html">Release Notes</a></li>
<li class="toctree-l1"><a class="reference internal" href="../whats_new_admin.html">What’s New in ownCloud 10.0.1</a></li>
<li class="toctree-l1"><a class="reference internal" href="../installation/index.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../configuration_database/index.html">Database Configuration</a></li>
<li class="toctree-l1"><a class="reference internal" href="../configuration_files/index.html">File Sharing and Management</a></li>
<li class="toctree-l1"><a class="reference internal" href="../maintenance/index.html">Maintenance</a></li>
<li class="toctree-l1"><a class="reference internal" href="../configuration_mimetypes/index.html">Mimetypes Management</a></li>
<li class="toctree-l1"><a class="reference internal" href="../configuration_server/index.html">Server Configuration</a></li>
<li class="toctree-l1"><a class="reference internal" href="../configuration_user/index.html">User Management</a></li>
<li class="toctree-l1"><a class="reference internal" href="../issues/index.html">Issues and Troubleshooting</a></li>
<li class="toctree-l1"><a class="reference internal" href="../enterprise/index.html">Enterprise Features</a></li>
</ul>
</ul>
</div>
</div>
</div>
<div class="col-md-9">
<div class="page-content">
<div class="section" id="how-to-install-and-configure-an-ldap-proxy-cache-server">
<h1>How To Install and Configure an LDAP Proxy-Cache Server<a class="headerlink" href="#how-to-install-and-configure-an-ldap-proxy-cache-server" title="Permalink to this headline">¶</a></h1>
<div class="section" id="background">
<h2>Background<a class="headerlink" href="#background" title="Permalink to this headline">¶</a></h2>
<p>To reduce network traffic overhead and avoid problems either logging in or performing user searches while sharing, it’s an excellent idea to implement an LDAP proxy cache.</p>
<p>An LDAP proxy cache server, similar to other kinds of caching servers, is a special type of LDAP replica. It can cache a range of LDAP records, often resulting in improved LDAP server performance.</p>
<p>Specifically, the records which need to be cached, for improved ownCloud performance, are:</p>
<ul class="simple">
<li>Users that are allowed to log in</li>
<li>Groups (limited to the allowed users)</li>
<li>Search fields (e.g., <code class="docutils literal"><span class="pre">sAMAccountName</span></code>, <code class="docutils literal"><span class="pre">cn</span></code>, <code class="docutils literal"><span class="pre">sn</span></code>, <code class="docutils literal"><span class="pre">givenName</span></code>, and <code class="docutils literal"><span class="pre">displayName</span></code>)</li>
</ul>
</div>
<div class="section" id="how-to-setup-the-server">
<h2>How To Setup the Server<a class="headerlink" href="#how-to-setup-the-server" title="Permalink to this headline">¶</a></h2>
<p>There’s not that much to it, just the following five steps:</p>
<ol class="arabic simple">
<li>Install OpenLDAP</li>
<li>Configure the server</li>
<li>Edit the default configuration directory</li>
<li>Perform a test search</li>
<li>Check the logs</li>
<li>Configure ownCloud LDAP app</li>
</ol>
<p>Let’s begin.</p>
</div>
<div class="section" id="install-openldap">
<h2>1. Install OpenLDAP<a class="headerlink" href="#install-openldap" title="Permalink to this headline">¶</a></h2>
<p>There are a number of <a class="reference external" href="https://en.wikipedia.org/wiki/List_of_LDAP_software">LDAP server implementations</a> available.
The one used in this guide is <a class="reference external" href="https://en.wikipedia.org/wiki/OpenLDAP">OpenLDAP</a>.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">While OpenLDAP does work on any operating system, for the purposes of this guide, we’ll be using a Debian-based Linux distribution.</p>
</div>
<p>Firstly, log in as root, and update your system, to ensure that you’re using the latest packages.:</p>
<div class="highlight-python"><div class="highlight"><pre>apt-get update && apt-get upgrade -y
</pre></div>
</div>
<p>Next, install OpenLDAP and its associated packages.:</p>
<div class="highlight-python"><div class="highlight"><pre>apt-get install slapd ldap-utils -y
</pre></div>
</div>
</div>
<div class="section" id="configure-the-server">
<h2>2. Configure the Server<a class="headerlink" href="#configure-the-server" title="Permalink to this headline">¶</a></h2>
<p>With OpenLDAP installed and running, you now need to configure the server.
One way of doing so, is to create a configuration file.
So, create <code class="docutils literal"><span class="pre">/etc/ldap/slapd.conf</span></code> with your text editor of choice, and add the following configuration to it.</p>
<div class="highlight-python"><div class="highlight"><pre># This an example of a config file:
# See slapd.conf(5)
# Global Directives:
# Schema and objectClass definitions
include /etc/ldap/schema/core.schema
include /etc/ldap/schema/cosine.schema
include /etc/ldap/schema/nis.schema
include /etc/ldap/schema/inetorgperson.schema
# Where the pid file is put. The init.d script
# will not stop the server if you change this.
pidfile /var/run/slapd/slapd.pid
# List of arguments that were passed to the server
argsfile /var/run/slapd/slapd.args
# Read slapd.conf(5) for possible values
# Change loglevel to "any" if you want to see everything.
loglevel none
# Where the dynamically loaded modules are stored
modulepath /usr/lib/ldap
# Here are the recommended modules:
# module for the target ldap-server
moduleload back_ldap.la
# module for your local database
moduleload back_hdb.la
# module for rewriting attributes
moduleload rwm
# caching module
moduleload pcache.la
# module to enable memberof in LDAP
moduleload memberof.la
# The maximum number of entries that is returned for a search operation
sizelimit 500
# The tool-threads parameter sets the actual amount of cpu's that is used
# for indexing.
tool-threads 1
# Type of backend, for example "ldap"
backend ldap
# If you only have read acces, set this to "yes"
readonly yes
# Set which protocol to use, we suggest "3"
protocol-version 3
# remember bind credentials
rebind-as-user
# If you want to save time and don't want to list all the refferals, set "yes"
norefs yes
# Same as above
chase-referrals no
# Specify the URL of your ldap server and the port.
# For unencrypted acces use the port 389, for encrypted 636
# If you have to use 636, you will also probably have to import
# the certificate of your target server. restart your webserver after you do.
uri "ldap://192.168.178.2:389"
# The base of your directory in database, for example "dc=ldap01,dc=com"
suffix "dc=ldap01,dc=com"
# rootdn directive for specifying a superuser on the database.
# If you don't have acces to the admin user, use the one you have.
rootdn "cn=admin,dc=ldap01,dc=com"
# Now we start initialising the modules
# First the rewrite module
overlay rwm
# Now we rewrite the attributes
rwm-map attribute uid sAMAccountName
rwm-map attribute dn distinguishedName
# Next one is optional, if you want memberof, for the groups,
# you have to load it.
overlay memberof
# Now we load the caching module
overlay pcache
# The directive enables proxy caching
# See slapo-pcache
# pcache <database> <max_entries> <numattrsets> <entry_limit> <cc_period>
# Parameters:
#
# <database> for cached entries.
# <max_entries> when reached - cache replacement is invoked
# <numattrsets> = pcacheAttrset
# <entry_limit> limit to the number of entries returned
# <cc_period> Consistency check time to wait
pcache hdb 100000 3 1000 100
# pcachePersist { TRUE | FALSE }
# Write cached results into the database
# Results remain in database after restart
pcachePersist TRUE
# Where the database file are physically stored for database #1
directory "/var/lib/ldap"
# Caching templates for general search
# pcacheAttrset <index> <attrs...>
# First set the index number
# Then set the attribute to cache
pcacheAttrset 0 1.1
# pcacheTemplate <template_string> <attrset_index> <ttl>
# First define the querry sting to cache
# Then reference the Attrset
# Last set the time-to-live
pcacheTemplate (&(|(objectClass=))) 0 3600
pcacheTemplate (objectClass=*) 0 3600
# User Name Field (Advanced Tab)
pcacheAttrset 1 displayname
pcacheTemplate (objectClass=*) 1 3600
# Group Field
pcacheAttrset 2 memberOf
pcacheTemplate (objectClass=*) 2 3600
</pre></div>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This configuration only caches queries from a single Active Directory server.
To cache queries from multiple Active Directory servers, a configuration is available below.</p>
</div>
<p>After you’ve done that, save the file, test that there are no errors in the configuration by running:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">slaptest</span> <span class="o">-</span><span class="n">f</span> <span class="o">/</span><span class="n">etc</span><span class="o">/</span><span class="n">ldap</span><span class="o">/</span><span class="n">slapd</span><span class="o">.</span><span class="n">conf</span>
</pre></div>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">If you see warnings in the console output, they are not crucial.</p>
</div>
</div>
<div class="section" id="enable-the-configuration-file">
<h2>3. Enable the configuration file<a class="headerlink" href="#enable-the-configuration-file" title="Permalink to this headline">¶</a></h2>
<p>Next, we need to tell OpenLDAP to use our configuration.
To do so, open <code class="docutils literal"><span class="pre">/etc/default/slapd</span></code> and add the following line to it:</p>
<div class="highlight-python"><div class="highlight"><pre>SLAPD_CONF=/etc/ldap/slapd.conf
</pre></div>
</div>
<p>With that done, restart OpenLDAP by running the following command:</p>
<div class="highlight-python"><div class="highlight"><pre>service slapd restart
</pre></div>
</div>
</div>
<div class="section" id="open-the-log">
<h2>4. Open the log<a class="headerlink" href="#open-the-log" title="Permalink to this headline">¶</a></h2>
<p>Open another terminal and see the systemlog with the following command.:</p>
<div class="highlight-python"><div class="highlight"><pre>tail -f /var/log/syslog | grep QUERY
</pre></div>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<blockquote>
<div>If there is no such file, you need to install rsyslog with.:</div></blockquote>
<p class="last">apt install rsyslog</p>
</div>
</div>
<div class="section" id="perform-a-test-search">
<h2>5. Perform a test search<a class="headerlink" href="#perform-a-test-search" title="Permalink to this headline">¶</a></h2>
<p>Now that the server’s installed, configured, and running, we next need to perform a search.
This will check that records are being correctly cached.
To do so, update the command below with values from your Active Directory server configuration, and then run it.:</p>
<div class="highlight-python"><div class="highlight"><pre>ldapsearch -h localhost -x -LLL -D "cn=admin,cn=users,dc=example,dc=com" -b "cn=users,dc=example,dc=com" -w "Password" "(cn=Administrator)" name
</pre></div>
</div>
<p>or</p>
<blockquote>
<div>ldapsearch -H ldaps://localhost:636 -x -LLL -D “cn=admin,cn=users,dc=example,dc=com” -b “cn=users,dc=example,dc=com” -W “(cn=Administrator)” name</div></blockquote>
<p>-h = host adress (Example: localhost or 192.168.1.1)
-H = host adress (Example: <a class="reference external" href="ldap://">ldap://</a> or ldaps:// hostname or ip and port :389 or :636 )
-x = simple authentication
-b = Search Base, (Example: “cn=Users,dc=example,dc=com”)
-D = User with permissions (Example: “cn=Admin,dc=example,dc=com”)
-LLL = Show only results, no extra information
-w = Password (“Password”)
-W = Password, will ask for password and hide your input
“(cn=Administrator)” = Filter the search
name = Show only this attributes</p>
<p>If you see results including: <code class="docutils literal"><span class="pre">"Query</span> <span class="pre">cachable"</span></code> and <code class="docutils literal"><span class="pre">"Query</span> <span class="pre">answered</span> <span class="pre">(x)</span> <span class="pre">times"</span></code>, then the setup works.</p>
</div>
<div class="section" id="configure-owncloud-ldap-app">
<h2>6. Configure ownCloud LDAP App<a class="headerlink" href="#configure-owncloud-ldap-app" title="Permalink to this headline">¶</a></h2>
<p>Login as ownCloud admin in your ownCloud server.</p>
<p>Click on the dropdown menu in the top-left corner next to “Files”, then on Apps.</p>
<p>Click on “Not enabled”, and enable the “LDAP user and group backend” App.</p>
<p>Go to the admin dropdown menu in the top-right corner, select “Admin”.</p>
<p>In the administration section, click on the left side on “LDAP”.</p>
<p>Configure Server-Tab</p>
<p>First enter the server address, either IP or DN.</p>
<p>You can click on the button to detect your servers port or enter it manualy.</p>
<p>Next, enter the dn of the user, you want to log in with and in the next line enter the password.</p>
<p>Then you can click on “detect base dn” or enter it manualy. then click on “test base dn”.</p>
<p>If you fullfill all the requirements you should get a green light and “configuration ok” message.</p>
<p>Configure Users</p>
<p>Select the objectclass for the users, for example “user”.</p>
<p>Verify your settings; where you will see the number of users being found.</p>
<p>Configure Login Attributes</p>
<p>A configuration appears by default, adjusted it to your users configuration.</p>
<p>If required, adjust the login paramethers additional login attributes.</p>
<p>You can check users with any of the allowed login options. You can adjust them or leave them the way they are.</p>
<p>Configure Groups</p>
<p>Select all the objectclasses for your groups, for example “group”. Verify your settings.</p>
<p>Configure Advanced</p>
<p>Configuration Active shoud be selected.</p>
<p>Adjust the Cache TTL (time to live) value as required.</p>
<p>ownCloud usualy autoselects the best settings for each AD configuration.</p>
<p>Check if the Group-Member association is “Member (AD)”.
That’s important for the users being shown in their respective groups.</p>
<p>Select “Nested groups”, if you have them.</p>
<p>Configure Expert</p>
<p>“Internal Username Attribute”</p>
<p>Here we need to set “cn” for the users being shown with their unique name.
If you leave that field empty, each user will get a unique uid as a string of numbers and letters.</p>
<p>Clear the Username and Groupname Mapping and test your configuration by clicking on the buttons below.</p>
<p>Navigate to Admin -> Users and check if all your users are listed properly, and shown in the right groups.</p>
<p>Go to the homepage of your ownCloud server and try to share something with one of your users</p>
<p>If everything is set up correctly, you now have an LDAP proxy server to your active directory that will</p>
<p>reduce the network traffic by caching the searches your perform.</p>
</div>
<div class="section" id="cache-multiple-active-directory-servers">
<h2>Cache Multiple Active Directory Servers<a class="headerlink" href="#cache-multiple-active-directory-servers" title="Permalink to this headline">¶</a></h2>
<p>If you have more than one that you want to cache, in <code class="docutils literal"><span class="pre">/etc/ldap/slapd.conf</span></code> add the following configuration instead,
adjusting as necessary. The ownCloud LDAP app settings are the same as in section 6.</p>
<div class="highlight-python"><div class="highlight"><pre># This an example of a config file:
# See slapd.conf(5)
# Global Directives:
# Schema and objectClass definitions
include /etc/ldap/schema/core.schema
include /etc/ldap/schema/cosine.schema
include /etc/ldap/schema/nis.schema
include /etc/ldap/schema/inetorgperson.schema
include /etc/ldap/schema/misc.schema
# Where the pid file is put. The init.d script
# will not stop the server if you change this.
pidfile /var/run/slapd/slapd.pid
# List of arguments that were passed to the server
argsfile /var/run/slapd/slapd.args
# Read slapd.conf(5) for possible values
# Change loglevel to "any" if you want to see everything.
loglevel none
# Where the dynamically loaded modules are stored
modulepath /usr/lib/ldap
# Here are the recommended modules:
# module for meta-database
moduleload back_meta.la
# module for the target ldap-server
moduleload back_ldap.la
# module for your local database
moduleload back_hdb.la
# module for rewriting attributes
moduleload rwm
# caching module
moduleload pcache.la
# module to enable memberof in ldap
moduleload memberof.la
# The maximum number of entries that is returned for a search operation
sizelimit 500
# The tool-threads parameter sets the actual amount of cpu's that is used
# for indexing.
tool-threads 1
# If you want to save time and don't want to list all the refferals, set "yes"
norefs yes
# Same as above
chase-referrals no
# See slapd-meta
# database type, for multiple ADS "meta" is required
database meta
# now we create a local ldap tree
# in our tree we put the multiple ADS on different branches
# we need a suffix, an admin, and a password
suffix "dc=owncloud,dc=com"
rootdn "cn=Administrator,cn=Users,dc=example,dc=com"
rootpw "Password"
# now we specify our ADs
# First-AD
# uri <protocol>://[<host>]/<naming context>
uri "ldap://first.ad.com:389/
cn=users,dc=first,dc=example,dc=com"
# here we need to set the virtual name to the real name
# the virtual name is a branch in our new created ldap tree
# suffixmassage <virtual naming context> <real naming context>
suffixmassage "cn=users,dc=first,dc=example,dc=com" "cn=users,dc=first,dc=ad,dc=com"
# authentication parameters
idassert-bind bindmethod=simple
binddn="cn=user01,cn=users,dc=first,dc=owncloud,dc=com"
credentials="Password01"
# Second-AD
uri "ldaps://second.ad.com:636/cn=users,dc=second,dc=example,dc=com"
suffixmassage "cn=users,dc=second,dc=example,dc=com" "cn=users,dc=second,dc=ad,dc=com"
idassert-bind bindmethod=simple
binddn="cn=user02,cn=users,dc=second,dc=owncloud,dc=com"
credentials="Password02"
# Now we start initialising the modules
# First the rewrite module
overlay rwm
# Now we rewrite the attributes
rwm-map attribute uid sAMAccountName
rwm-map attribute dn distinguishedName
# Next one is optional, if you want memberof, for the groups,
# you have to load it.
overlay memberof
# Now we load the caching module
overlay pcache
# The directive enables proxy caching
# See slapo-pcache
# pcache <database> <max_entries> <numattrsets> <entry_limit> <cc_period>
# Parameters:
#
# <database> for cached entries.
# <max_entries> when reached - cache replacement is invoked
# <numattrsets> = pcacheAttrset
# <entry_limit> limit to the number of entries returned
# <cc_period> Consistency check time to wait
pcache hdb 100000 3 1000 100
# pcachePersist { TRUE | FALSE }
# Write cached results into the database
# Results remain in database after restart
pcachePersist TRUE
# Where the database files are physically stored for database #1
directory "/var/lib/ldap"
# Caching templates for general search
# pcacheAttrset <index> <attrs...>
# First set the index number
# Then set the attribute to cache
pcacheAttrset 0 1.1
# pcacheTemplate <template_string> <attrset_index> <ttl>
# First define the query sting to cache
# Then reference the Attrset
# Last set the time-to-live
pcacheTemplate (&(|(objectClass=))) 0 3600
pcacheTemplate (objectClass=*) 0 3600
# User Name Field (Advanced Tab)
pcacheAttrset 1 displayname
pcacheTemplate (objectClass=*) 1 3600
# Group Field
pcacheAttrset 2 memberOf
pcacheTemplate (objectClass=*) 2 3600
</pre></div>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
</div>
</div>
</body>
</html>