?i»?

Your IP : 3.145.179.177


Current Path : /home/s/c/g/scgforma/www/cloud/core/doc/admin/configuration_user/
Upload File :
Current File : /home/s/c/g/scgforma/www/cloud/core/doc/admin/configuration_user/user_auth_ldap.html

<!DOCTYPE html>


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>User authentication with LDAP &mdash; Nextcloud 13 Administration Manual 13 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:     '13',
        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="Nextcloud 13 Administration Manual 13 documentation" href="../contents.html" />
    <link rel="up" title="User management" href="index.html" />
    <link rel="next" title="LDAP user cleanup" href="user_auth_ldap_cleanup.html" />
    <link rel="prev" title="User authentication with IMAP, SMB, and FTP" href="user_auth_ftp_smb_imap.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">
				<div class="col-md-3">
					<div class="sidebar">
            <h1>Nextcloud 13 Administration Manual</h1>
            
            <div class="sidebar-search">
              <form class="headersearch" 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 class="menu-support-container">
								<ul id="menu-support" class="menu">
									<ul>
                    <li><a href="../contents.html">Table of Contents</a></li>
									</ul>
                  <ul class="current">
<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="../installation/index.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../configuration_server/index.html">Server configuration</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">User management</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="user_configuration.html">User management</a></li>
<li class="toctree-l2"><a class="reference internal" href="reset_admin_password.html">Resetting a lost admin password</a></li>
<li class="toctree-l2"><a class="reference internal" href="reset_user_password.html">Resetting a user password</a></li>
<li class="toctree-l2"><a class="reference internal" href="user_password_policy.html">User password policy</a></li>
<li class="toctree-l2"><a class="reference internal" href="two_factor-auth.html">Two factor authentication</a></li>
<li class="toctree-l2"><a class="reference internal" href="user_auth_ftp_smb_imap.html">User authentication with IMAP, SMB, and FTP</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="">User authentication with LDAP</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#configuration">Configuration</a></li>
<li class="toctree-l3"><a class="reference internal" href="#advanced-settings">Advanced settings</a></li>
<li class="toctree-l3"><a class="reference internal" href="#expert-settings">Expert settings</a></li>
<li class="toctree-l3"><a class="reference internal" href="#testing-the-configuration">Testing the configuration</a></li>
<li class="toctree-l3"><a class="reference internal" href="#additional-configuration-options-via-occ">Additional configuration options via occ</a></li>
<li class="toctree-l3"><a class="reference internal" href="#nextcloud-avatar-integration">Nextcloud avatar integration</a></li>
<li class="toctree-l3"><a class="reference internal" href="#troubleshooting-tips-and-tricks">Troubleshooting, tips and tricks</a></li>
<li class="toctree-l3"><a class="reference internal" href="#nextcloud-ldap-internals">Nextcloud LDAP internals</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="user_auth_ldap_cleanup.html">LDAP user cleanup</a></li>
<li class="toctree-l2"><a class="reference internal" href="user_auth_ldap_api.html">The LDAP configuration API</a></li>
<li class="toctree-l2"><a class="reference internal" href="user_provisioning_api.html">User provisioning API</a></li>
</ul>
</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="../file_workflows/index.html">File workflows</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_mimetypes/index.html">Mimetypes 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="../issues/index.html">Issues and troubleshooting</a></li>
</ul>

								</ul>
							</div>
					</div>
				</div>
        

				<div class="col-md-9">
					<div class="page-content">
            
<ul class="prevnext-title list-unstyled list-inline">
  <li class="prev">
    <a href="user_auth_ftp_smb_imap.html" title="Previous Chapter: User authentication with IMAP, SMB, and FTP"><span class="glyphicon glyphicon-chevron-left visible-sm"></span><span class="hidden-sm">&laquo; User authentication with IMAP, SMB, and FTP</span>
    </a>
  </li>
  <li class="next">
    <a href="user_auth_ldap_cleanup.html" title="Next Chapter: LDAP user cleanup"><span class="glyphicon glyphicon-chevron-right visible-sm"></span><span class="hidden-sm">LDAP user cleanup &raquo;</span>
    </a>
  </li>
</ul>
						
  <div class="section" id="user-authentication-with-ldap">
<h1>User authentication with LDAP<a class="headerlink" href="#user-authentication-with-ldap" title="Permalink to this headline">¶</a></h1>
<p>Nextcloud ships with an LDAP application to allow LDAP users (including Active
Directory) to appear in your Nextcloud user listings. These users will
authenticate to Nextcloud with their LDAP credentials, so you don&#8217;t have to
create separate Nextcloud user accounts for them. You will manage their Nextcloud
group memberships, quotas, and sharing permissions just like any other Nextcloud
user.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">The PHP LDAP module is required; this is supplied by <code class="docutils literal"><span class="pre">php5-ldap</span></code> on
Debian/Ubuntu, and <code class="docutils literal"><span class="pre">php-ldap</span></code> on CentOS/Red Hat/Fedora. PHP 5.6+ is
required in Nextcloud.</p>
</div>
<p>The LDAP application supports:</p>
<ul class="simple">
<li>LDAP group support</li>
<li>File sharing with Nextcloud users and groups</li>
<li>Access via WebDAV and Nextcloud Desktop Client</li>
<li>Versioning, external Storage and all other Nextcloud features</li>
<li>Seamless connectivity to Active Directory, with no extra configuration
required</li>
<li>Support for primary groups in Active Directory</li>
<li>Auto-detection of LDAP attributes such as base DN, email, and the LDAP server
port number</li>
<li>Only read access to your LDAP (edit or delete of users on your LDAP is not
supported)</li>
<li>Optional: Allow users to change their LDAP password from Nextcloud</li>
</ul>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">The LDAP app is not compatible with the <code class="docutils literal"><span class="pre">User</span> <span class="pre">backend</span> <span class="pre">using</span> <span class="pre">remote</span>
<span class="pre">HTTP</span> <span class="pre">servers</span></code> app. You cannot use both of them at the same time.</p>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">A non-blocking or correctly configured SELinux setup is needed
for the LDAP backend to work. Please refer to the <a class="reference internal" href="../installation/selinux_configuration.html#selinux-config-label"><span>SELinux configuration</span></a>.</p>
</div>
<div class="section" id="configuration">
<h2>Configuration<a class="headerlink" href="#configuration" title="Permalink to this headline">¶</a></h2>
<p>First enable the <code class="docutils literal"><span class="pre">LDAP</span> <span class="pre">user</span> <span class="pre">and</span> <span class="pre">group</span> <span class="pre">backend</span></code> app on the Apps page in
Nextcloud. Then go to your Admin page to configure it.</p>
<p>The LDAP configuration panel has four tabs. A correctly completed first tab
(&#8220;Server&#8221;) is mandatory to access the other tabs. A green indicator lights when
the configuration is correct. Hover your cursor over the fields to see some
pop-up tooltips.</p>
<div class="section" id="server-tab">
<h3>Server tab<a class="headerlink" href="#server-tab" title="Permalink to this headline">¶</a></h3>
<p>Start with the Server tab. You may configure multiple servers if you have them.
At a minimum you must supply the LDAP server&#8217;s hostname. If your server requires
authentication, enter your credentials on this tab. Nextcloud will then attempt
to auto-detect the server&#8217;s port and base DN. The base DN and port are
mandatory, so if Nextcloud cannot detect them you must enter them manually.</p>
<div class="figure">
<img alt="LDAP wizard, server tab" src="../_images/ldap-wizard-1-server.png" />
</div>
<dl class="docutils">
<dt>Server configuration:</dt>
<dd>Configure one or more LDAP servers. Click the <strong>Delete Configuration</strong>
button to remove the active configuration.</dd>
<dt>Host:</dt>
<dd><p class="first">The host name or IP address of the LDAP server. It can also be a <strong>ldaps://</strong>
URI. If you enter the port number, it speeds up server detection.</p>
<p>Examples:</p>
<ul class="last simple">
<li><em>directory.my-company.com</em></li>
<li><em>ldaps://directory.my-company.com</em></li>
<li><em>directory.my-company.com:9876</em></li>
</ul>
</dd>
<dt>Port:</dt>
<dd><p class="first">The port on which to connect to the LDAP server. The field is disabled in the
beginning of a new configuration. If the LDAP server is running on a standard
port, the port will be detected automatically. If you are using a
non-standard port, Nextcloud will attempt to detect it. If this fails you must
enter the port number manually.</p>
<p>Example:</p>
<ul class="last simple">
<li><em>389</em></li>
</ul>
</dd>
<dt>User DN:</dt>
<dd><p class="first">The name as DN of a user who has permissions to do searches in the LDAP
directory. Leave it empty for anonymous access. We recommend that you have a
special LDAP system user for this.</p>
<p>Example:</p>
<ul class="last simple">
<li><em>uid=nextcloudsystemuser,cn=sysusers,dc=my-company,dc=com</em></li>
</ul>
</dd>
<dt>Password:</dt>
<dd>The password for the user given above. Empty for anonymous access.</dd>
<dt>Base DN:</dt>
<dd><p class="first">The base DN of LDAP, from where all users and groups can be reached. You may
enter multiple base DNs, one per line. (Base DNs for users and groups can be
set in the Advanced tab.) This field is mandatory. Nextcloud attempts to
determine the Base DN according to the provided User DN or the provided
Host, and you must enter it manually if Nextcloud does not detect it.</p>
<p>Example:</p>
<ul class="last simple">
<li><em>dc=my-company,dc=com</em></li>
</ul>
</dd>
</dl>
</div>
<div class="section" id="users-tab">
<h3>Users tab<a class="headerlink" href="#users-tab" title="Permalink to this headline">¶</a></h3>
<p>Use this to control which LDAP users are listed as Nextcloud users on your
Nextcloud server. In order to control which LDAP users can login to your Nextcloud
server use the <strong>Login Attributes</strong> tab. Those LDAP users who have access but are not listed
as users (if there are any) will be hidden users. You may bypass the form fields
and enter a raw LDAP filter if you prefer.</p>
<div class="figure">
<img alt="User filter" src="../_images/ldap-wizard-2-user.png" />
</div>
<dl class="docutils">
<dt>Only those object classes:</dt>
<dd>Nextcloud will determine the object classes that are typically available for
user objects in your LDAP. Nextcloud will automatically select the object
class that returns the highest amount of users. You may select multiple
object classes.</dd>
<dt>Only from those groups:</dt>
<dd><p class="first">If your LDAP server supports the <code class="docutils literal"><span class="pre">member-of-overlay</span></code> in LDAP filters, you
can define that only users from one or more certain groups are allowed to
appear in user listings in Nextcloud. By default, no value will be selected.
You may select multiple groups.</p>
<p class="last">If your LDAP server does not support the <code class="docutils literal"><span class="pre">member-of-overlay</span></code> in LDAP filters,
the input field is disabled. Please contact your LDAP administrator.</p>
</dd>
<dt>Edit LDAP Query:</dt>
<dd><p class="first">Clicking on this text toggles the filter mode and you can enter the raw LDAP
filter directly. Example:</p>
<div class="last highlight-python"><div class="highlight"><pre>(&amp;(objectClass=inetOrgPerson)(memberOf=cn=nextcloudusers,ou=groups,
dc=example,dc=com))
</pre></div>
</div>
</dd>
<dt>x users found:</dt>
<dd>This is an indicator that tells you approximately how many users will be
listed in Nextcloud. The number updates automatically after any changes.</dd>
</dl>
</div>
<div class="section" id="login-attributes-tab">
<h3>Login attributes tab<a class="headerlink" href="#login-attributes-tab" title="Permalink to this headline">¶</a></h3>
<p>The settings in the Login Attributes tab determine which LDAP users can log in to
your Nextcloud system and which attribute or attributes the provided login name
is matched against (e.g. LDAP/AD username, email address). You may select
multiple user details. (You may bypass the form fields and enter a raw LDAP
filter if you prefer.)</p>
<p>You may override your User Filter settings on the Users tab by using a raw
LDAP filter.</p>
<div class="figure">
<img alt="Login filter" src="../_images/ldap-wizard-3-login.png" />
</div>
<dl class="docutils">
<dt>LDAP Username:</dt>
<dd>If this value is checked, the login value will be compared to the username in
the LDAP directory. The corresponding attribute, usually <em>uid</em> or
<em>samaccountname</em> will be detected automatically by Nextcloud.</dd>
<dt>LDAP Email Address:</dt>
<dd>If this value is checked, the login value will be compared to an email address
in the LDAP directory; specifically, the <em>mailPrimaryAddress</em> and <em>mail</em>
attributes.</dd>
<dt>Other Attributes:</dt>
<dd>This multi-select box allows you to select other attributes for the
comparison. The list is generated automatically from the user object
attributes in your LDAP server.</dd>
<dt>Edit LDAP Query:</dt>
<dd><p class="first">Clicking on this text toggles the filter mode and you can enter the raw LDAP
filter directly.</p>
<p>The <strong>%uid</strong> placeholder is replaced with the login name entered by the
user upon login.</p>
<p>Examples:</p>
<ul class="last">
<li><p class="first">only username:</p>
<div class="highlight-python"><div class="highlight"><pre>(&amp;(objectClass=inetOrgPerson)(memberOf=cn=nextcloudusers,ou=groups,
dc=example,dc=com)(uid=%uid)
</pre></div>
</div>
</li>
<li><p class="first">username or email address:</p>
<div class="highlight-python"><div class="highlight"><pre>((&amp;(objectClass=inetOrgPerson)(memberOf=cn=nextcloudusers,ou=groups,
dc=example,dc=com)(|(uid=%uid)(mail=%uid)))
</pre></div>
</div>
</li>
</ul>
</dd>
</dl>
</div>
<div class="section" id="groups-tab">
<h3>Groups tab<a class="headerlink" href="#groups-tab" title="Permalink to this headline">¶</a></h3>
<p>By default, no LDAP groups will be available in Nextcloud. The settings in the
Groups tab determine which groups will be available in Nextcloud. You may
also elect to enter a raw LDAP filter instead.</p>
<div class="figure">
<img alt="Group filter" src="../_images/ldap-wizard-4-group.png" />
</div>
<dl class="docutils">
<dt>Only these object classes:</dt>
<dd>Nextcloud will determine the object classes that are typically available for
group objects in your LDAP server. Nextcloud will only list object
classes that return at least one group object. You can select multiple
object classes. A typical object class is &#8220;group&#8221;, or &#8220;posixGroup&#8221;.</dd>
<dt>Only from these groups:</dt>
<dd>Nextcloud will generate a list of available groups found in your LDAP server.
Then you select the group or groups that get access to your Nextcloud
server.</dd>
<dt>Edit LDAP Query:</dt>
<dd><p class="first">Clicking on this text toggles the filter mode and you can enter the raw LDAP
filter directly.</p>
<p>Example:</p>
<ul class="last simple">
<li><em>objectClass=group</em></li>
<li><em>objectClass=posixGroup</em></li>
</ul>
</dd>
<dt>y groups found:</dt>
<dd>This tells you approximately how many groups will be available in Nextcloud.
The number updates automatically after any change.</dd>
</dl>
</div>
</div>
<div class="section" id="advanced-settings">
<h2>Advanced settings<a class="headerlink" href="#advanced-settings" title="Permalink to this headline">¶</a></h2>
<p>The LDAP Advanced Setting section contains options that are not needed for a
working connection. This provides controls to disable the current
configuration,
configure replica hosts, and various performance-enhancing options.</p>
<p>The Advanced Settings are structured into three parts:</p>
<ul class="simple">
<li>Connection Settings</li>
<li>Directory Settings</li>
<li>Special Attributes</li>
</ul>
<div class="section" id="connection-settings">
<h3>Connection settings<a class="headerlink" href="#connection-settings" title="Permalink to this headline">¶</a></h3>
<div class="figure">
<img alt="Advanced settings" src="../_images/ldap-advanced-1-connection.png" />
</div>
<dl class="docutils">
<dt>Configuration Active:</dt>
<dd>Enables or Disables the current configuration. By default, it is turned off.
When Nextcloud makes a successful test connection it is automatically turned
on.</dd>
<dt>Backup (Replica) Host:</dt>
<dd><p class="first">If you have a backup LDAP server, enter the connection settings here.
Nextcloud will then automatically connect to the backup when the main server
cannot be reached. The backup server must be a replica of the main server so
that the object UUIDs match.</p>
<p>Example:</p>
<ul class="last simple">
<li><em>directory2.my-company.com</em></li>
</ul>
</dd>
<dt>Backup (Replica) Port:</dt>
<dd><p class="first">The connection port of the backup LDAP server. If no port is given,
but only a host, then the main port (as specified above) will be used.</p>
<p>Example:</p>
<ul class="last simple">
<li><em>389</em></li>
</ul>
</dd>
<dt>Disable Main Server:</dt>
<dd>You can manually override the main server and make Nextcloud only connect to
the backup server. This is useful for planned downtimes.</dd>
<dt>Turn off SSL certificate validation:</dt>
<dd>Turns off SSL certificate checking. Use it for testing only!</dd>
<dt>Cache Time-To-Live:</dt>
<dd><p class="first">A cache is introduced to avoid unnecessary LDAP traffic, for example caching
usernames so they don&#8217;t have to be looked up for every page, and speeding up
loading of the Users page. Saving the configuration empties the cache. The
time is given in seconds.</p>
<p>Note that almost every PHP request requires a new connection to the LDAP
server. If you require fresh PHP requests we recommend defining a minimum
lifetime of 15s or so, rather than completely eliminating the cache.</p>
<p>Examples:</p>
<ul class="last simple">
<li>ten minutes: <em>600</em></li>
<li>one hour: <em>3600</em></li>
</ul>
</dd>
</dl>
<p>See the Caching section below for detailed information on how the cache
operates.</p>
</div>
<div class="section" id="directory-settings">
<span id="ldap-directory-settings"></span><h3>Directory settings<a class="headerlink" href="#directory-settings" title="Permalink to this headline">¶</a></h3>
<div class="figure">
<img alt="Directory settings." src="../_images/ldap-advanced-2-directory.png" />
</div>
<dl class="docutils">
<dt>User Display Name Field:</dt>
<dd><p class="first">The attribute that should be used as display name in Nextcloud.</p>
<ul class="last simple">
<li>Example: <em>displayName</em></li>
</ul>
</dd>
<dt>2nd User Display Name Field:</dt>
<dd>An optional second attribute displayed in brackets after the display name,
for example using the <code class="docutils literal"><span class="pre">mail</span></code> attribute displays as <code class="docutils literal"><span class="pre">Molly</span> <span class="pre">Foo</span>
<span class="pre">(molly&#64;example.com)</span></code>.</dd>
<dt>Base User Tree:</dt>
<dd><p class="first">The base DN of LDAP, from where all users can be reached. This must be a
complete DN, regardless of what you have entered for your Base DN in the
Basic setting. You can specify multiple base trees, one on each line.</p>
<ul class="last">
<li><p class="first">Example:</p>
<div class="line-block">
<div class="line"><em>cn=programmers,dc=my-company,dc=com</em></div>
<div class="line"><em>cn=designers,dc=my-company,dc=com</em></div>
</div>
</li>
</ul>
</dd>
<dt>User Search Attributes:</dt>
<dd><p class="first">These attributes are used when searches for users are performed, for example
in the share dialogue. The user display name attribute is the
default. You may list multiple attributes, one per line.</p>
<p>If an attribute is not available on a user object, the user will not be
listed, and will be unable to login. This also affects the display name
attribute. If you override the default you must specify the display name
attribute here.</p>
<ul class="last">
<li><p class="first">Example:</p>
<div class="line-block">
<div class="line"><em>displayName</em></div>
<div class="line"><em>mail</em></div>
</div>
</li>
</ul>
</dd>
<dt>Group Display Name Field:</dt>
<dd><p class="first">The attribute that should be used as Nextcloud group name. Nextcloud allows a
limited set of characters (a-zA-Z0-9.-_&#64;). Once a group name is assigned it
cannot be changed.</p>
<ul class="last simple">
<li>Example: <em>cn</em></li>
</ul>
</dd>
<dt>Base Group Tree:</dt>
<dd><p class="first">The base DN of LDAP, from where all groups can be reached. This must be a
complete DN, regardless of what you have entered for your Base DN in the
Basic setting. You can specify multiple base trees, one in each line.</p>
<ul class="last">
<li><p class="first">Example:</p>
<div class="line-block">
<div class="line"><em>cn=barcelona,dc=my-company,dc=com</em></div>
<div class="line"><em>cn=madrid,dc=my-company,dc=com</em></div>
</div>
</li>
</ul>
</dd>
<dt>Group Search Attributes:</dt>
<dd><p class="first">These attributes are used when a search for groups is done, for example in
the share dialogue. By default the group display name attribute as specified
above is used. Multiple attributes can be given, one in each line.</p>
<p>If you override the default, the group display name attribute will not be
taken into account, unless you specify it as well.</p>
<ul class="last">
<li><p class="first">Example:</p>
<div class="line-block">
<div class="line"><em>cn</em></div>
<div class="line"><em>description</em></div>
</div>
</li>
</ul>
</dd>
<dt>Group Member association:</dt>
<dd><p class="first">The attribute that is used to indicate group memberships, i.e. the attribute
used by LDAP groups to refer to their users.</p>
<p>Nextcloud detects the value automatically. You should only change it if you
have a very valid reason and know what you are doing.</p>
<ul class="last simple">
<li>Example: <em>uniquemember</em></li>
</ul>
</dd>
<dt>Nested groups:</dt>
<dd><p class="first">Enable group member retrieval from sub groups.</p>
<p class="last">To allow user listing and login from nested groups, please see <strong>User listing
and login per nested groups</strong> in the section <strong>Troubleshooting, Tips and
Tricks</strong>.</p>
</dd>
<dt>Enable LDAP password changes per user:</dt>
<dd><p class="first">Allow LDAP users to change their password and allow Super Administrators and Group Administrators to change the password of their LDAP users.</p>
<p>To enable this feature, the following requirements have to be met:</p>
<ul class="simple">
<li>General requirements:</li>
</ul>
<blockquote>
<div><ul class="simple">
<li>Access control policies must be configured on the LDAP server to grant permissions for password changes. The User DN as configured in <em>Server Settings</em> needs to have write permissions in order to update the userPassword attribute.</li>
<li>Passwords are sent in plaintext to the LDAP server. Therefore, transport encryption must be used for the communication between Nextcloud and the LDAP server, e.g. employ LDAPS.</li>
<li>Enabling password hashing on the LDAP server is highly recommended. While Active Directory stores passwords in a one-way format by default, OpenLDAP users could configure the <code class="docutils literal"><span class="pre">ppolicy_hash_cleartext</span></code> directive of the ppolicy overlay that ships with OpenLDAP.</li>
</ul>
</div></blockquote>
<ul class="simple">
<li>Additional requirements for Active Directory:</li>
</ul>
<blockquote class="last">
<div><ul class="simple">
<li>At least a 128-bit transport encryption must be used for the communication between Nextcloud and the LDAP server.</li>
<li>Make sure that the <code class="docutils literal"><span class="pre">fUserPwdSupport</span></code> char of the dSHeuristics is configured to employ the <code class="docutils literal"><span class="pre">userPassword</span></code> attribute as <code class="docutils literal"><span class="pre">unicodePwd</span></code> alias. While this is set accordingly on AD LDS by default, this is not the case on AD DS.</li>
</ul>
</div></blockquote>
</dd>
<dt>Default password policy DN:</dt>
<dd><p class="first">This feature requires OpenLDAP with ppolicy. The DN of a default password policy will be used for password expiry handling in the absence of any user specific password policy. Password expiry handling features the following:</p>
<ul class="simple">
<li>When a LDAP password is about to expire, display a warning message to the user showing the number of days left before it expires. Password expiry warnings are displayed through the notifications app for Nextcloud.</li>
<li>Prompt LDAP users with expired passwords to reset their password during login, provided that an adequate number of grace logins is still available.</li>
</ul>
<p>Leave the setting empty to keep password expiry handling disabled.</p>
<p>For the password expiry handling feature to work, LDAP password changes per user must be enabled and the LDAP server must be running OpenLDAP with its ppolicy module configured accordingly.</p>
<ul class="last">
<li><p class="first">Example:</p>
<div class="line-block">
<div class="line"><em>cn=default,ou=policies,dc=my-company,dc=com</em></div>
</div>
</li>
</ul>
</dd>
</dl>
</div>
<div class="section" id="special-attributes">
<h3>Special attributes<a class="headerlink" href="#special-attributes" title="Permalink to this headline">¶</a></h3>
<div class="figure">
<img alt="Special Attributes." src="../_images/ldap-advanced-3-attributes.png" />
</div>
<dl class="docutils">
<dt>Quota Field:</dt>
<dd><p class="first">Nextcloud can read an LDAP attribute and set the user quota according to its
value. Specify the attribute here, and it will return human-readable values,
e.g. &#8220;2 GB&#8221;. Any quota set in LDAP overrides quotas set on the Nextcloud user
management page.</p>
<ul class="last simple">
<li>Example: <em>NextcloudQuota</em></li>
</ul>
</dd>
<dt>Quota Default:</dt>
<dd><p class="first">Override Nextcloud default quota for LDAP users who do not have a quota set in
the Quota Field.</p>
<ul class="last simple">
<li>Example: <em>15 GB</em></li>
</ul>
</dd>
<dt>Email Field:</dt>
<dd><p class="first">Set the user&#8217;s email from their LDAP attribute. Leave it empty for default
behavior.</p>
<ul class="last simple">
<li>Example: <em>mail</em></li>
</ul>
</dd>
<dt>User Home Folder Naming Rule:</dt>
<dd><p class="first">By default, the Nextcloud server creates the user directory in your Nextcloud
data directory and gives it the Nextcloud username, .e.g <code class="docutils literal"><span class="pre">/var/www/nextcloud/data/alice</span></code>. You may want to override this setting and name it after an LDAP
attribute value. The attribute can also return an absolute path, e.g.
<code class="docutils literal"><span class="pre">/mnt/storage43/alice</span></code>. Leave it empty for default behavior.</p>
<ul class="last simple">
<li>Example: <em>cn</em></li>
</ul>
</dd>
</dl>
<p>In new Nextcloud installations the home folder rule is enforced. This means that once you set a home folder naming rule (get a home folder from an LDAP attribute), it must be available for all users. If it isn&#8217;t available for a user, then that user will not be able to login. Also, the filesystem will not be set up for that user, so their file shares will not be available to other users.</p>
<p>In migrated Nextcloud installations the old behavior still applies, which is using the Nextcloud username as the home folder when an LDAP attribute is not set. You may change this enforcing the home folder rule with the <code class="docutils literal"><span class="pre">occ</span></code> command in Nextcloud, like this example on Ubuntu:</p>
<div class="highlight-python"><div class="highlight"><pre>sudo -u www-data php occ config:app:set user_ldap enforce_home_folder_naming_rule --value=1
</pre></div>
</div>
</div>
</div>
<div class="section" id="expert-settings">
<h2>Expert settings<a class="headerlink" href="#expert-settings" title="Permalink to this headline">¶</a></h2>
<div class="figure">
<img alt="Expert settings." src="../_images/ldap-expert.png" />
</div>
<p>In the Expert Settings fundamental behavior can be adjusted to your needs. The
configuration should be well-tested before starting production use.</p>
<dl class="docutils">
<dt>Internal Username:</dt>
<dd><p class="first">The internal username is the identifier in Nextcloud for LDAP users. By default
it will be created from the UUID attribute. The UUID attribute ensures that
the username is unique, and that characters do not need to be converted. Only
these characters are allowed: [a-zA-Z0-9_.&#64;-]. Other characters are
replaced with their ASCII equivalents, or are simply omitted.</p>
<p>The LDAP backend ensures that there are no duplicate internal usernames in
Nextcloud, i.e. that it is checking all other activated user backends
(including local Nextcloud users). On collisions a random number (between 1000
and 9999) will be attached to the retrieved value. For example, if &#8220;alice&#8221;
exists, the next username may be &#8220;alice_1337&#8221;.</p>
<p>The internal username is the default name for the user home folder in
Nextcloud. It is also a part of remote URLs, for instance for all *DAV
services.</p>
<p>You can override all of this with the Internal Username setting. Leave it
empty for default behavior. Changes will affect only newly mapped LDAP users.</p>
<ul class="last simple">
<li>Example: <em>uid</em></li>
</ul>
</dd>
<dt>Override UUID detection</dt>
<dd><p class="first">By default, Nextcloud auto-detects the UUID attribute. The UUID attribute is
used to uniquely identify LDAP users and groups. The internal username will
be created based on the UUID, if not specified otherwise.</p>
<p>You can override the setting and pass an attribute of your choice. You must
make sure that the attribute of your choice can be fetched for both users and
groups and it is unique. Leave it empty for default behavior. Changes will
have effect only on newly mapped LDAP users and groups. It also will
have effect when a user&#8217;s or group&#8217;s DN changes and an old UUID was cached,
which will result in a new user. Because of this, the setting should be
applied before putting Nextcloud in production use and clearing the bindings
(see the <code class="docutils literal"><span class="pre">User</span> <span class="pre">and</span> <span class="pre">Group</span> <span class="pre">Mapping</span></code> section below).</p>
<ul class="last simple">
<li>Example: <em>cn</em></li>
</ul>
</dd>
<dt>Username-LDAP User Mapping</dt>
<dd><p class="first">Nextcloud uses usernames as keys to store and assign data. In order to
precisely identify and recognize users, each LDAP user will have a internal
username in Nextcloud. This requires a mapping from Nextcloud username to LDAP
user. The created username is mapped to the UUID of the LDAP user.
Additionally the DN is cached as well to reduce LDAP interaction, but it is
not used for identification. If the DN changes, the change will be detected by
Nextcloud by checking the UUID value.</p>
<p>The same is valid for groups.</p>
<p class="last">The internal Nextcloud name is used all over in Nextcloud. Clearing the Mappings
will have leftovers everywhere. Never clear the mappings in a production
environment, but only in a testing or experimental server.</p>
</dd>
</dl>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">Clearing the Mappings is not configuration sensitive, it affects all LDAP
configurations!</p>
</div>
</div>
<div class="section" id="testing-the-configuration">
<h2>Testing the configuration<a class="headerlink" href="#testing-the-configuration" title="Permalink to this headline">¶</a></h2>
<p>The <strong>Test Configuration</strong> button checks the values as currently given in the
input fields. You do not need to save before testing. By clicking on the
button, Nextcloud will try to bind to the Nextcloud server using the
settings currently given in the input fields. If the binding fails you&#8217;ll see a
yellow banner with the error message &#8220;The configuration is invalid. Please have
a look at the logs for further details.&#8221;</p>
<p>When the configuration test reports success, save your settings and check if the
users and groups are fetched correctly on the Users page.</p>
</div>
<div class="section" id="additional-configuration-options-via-occ">
<h2>Additional configuration options via occ<a class="headerlink" href="#additional-configuration-options-via-occ" title="Permalink to this headline">¶</a></h2>
<p>Few configuration settings can only be set on command line via <code class="docutils literal"><span class="pre">occ</span></code>.</p>
<div class="section" id="attribute-update-interval">
<h3>Attribute update interval<a class="headerlink" href="#attribute-update-interval" title="Permalink to this headline">¶</a></h3>
<p>The LDAP backend will update user information that is used within Nextcloud
with the values provided by the LDAP server. For instance these are email,
quota or the avatar. This happens on every login, the first detection of a user
from LDAP and regularly by a background job.</p>
<p>The interval value determines the time between updates of the values and is
used to avoid frequent overhead, including time-expensive write actions to
the database.</p>
<p>The interval is described in seconds and it defaults to 86400 equalling a day.
It is not a per-configuration option.</p>
<p>The value can be modified by:</p>
<div class="highlight-python"><div class="highlight"><pre>sudo -u www-data php occ config:app:set user_ldap updateAttributesInterval --value=86400
</pre></div>
</div>
<p>A value of 0 will update it on every of the named occasions.</p>
</div>
</div>
<div class="section" id="nextcloud-avatar-integration">
<h2>Nextcloud avatar integration<a class="headerlink" href="#nextcloud-avatar-integration" title="Permalink to this headline">¶</a></h2>
<p>Nextcloud supports user profile pictures, which are also called avatars. If a user
has a photo stored in the <em>jpegPhoto</em> or <em>thumbnailPhoto</em> attribute on your LDAP
server, it will be used as their avatar. In this case the user cannot alter their
avatar (on their Personal page) as it must be changed in LDAP. <em>jpegPhoto</em> is
preferred over <em>thumbnailPhoto</em>.</p>
<div class="figure">
<img alt="Profile picture fetched from LDAP." src="../_images/ldap-fetched-avatar.png" />
</div>
<p>If the <em>jpegPhoto</em> or <em>thumbnailPhoto</em> attribute is not set or empty, then
users can upload and manage their avatars on their Nextcloud Personal pages.
Avatars managed in Nextcloud are not stored in LDAP.</p>
<p>The <em>jpegPhoto</em> or <em>thumbnailPhoto</em> attribute is fetched once a day to make
sure the current photo from LDAP is used in Nextcloud. LDAP avatars override
Nextcloud avatars, and when an LDAP avatar is deleted then the most recent
Nextcloud avatar replaces it.</p>
<p>Photos served from LDAP are automatically cropped and resized in Nextcloud. This
affects only the presentation, and the original image is not changed.</p>
</div>
<div class="section" id="troubleshooting-tips-and-tricks">
<h2>Troubleshooting, tips and tricks<a class="headerlink" href="#troubleshooting-tips-and-tricks" title="Permalink to this headline">¶</a></h2>
<div class="section" id="ssl-certificate-verification-ldaps-tls">
<h3>SSL certificate verification (LDAPS, TLS)<a class="headerlink" href="#ssl-certificate-verification-ldaps-tls" title="Permalink to this headline">¶</a></h3>
<p>A common mistake with SSL certificates is that they may not be known to PHP.
If you have trouble with certificate validation make sure that</p>
<ul class="simple">
<li>You have the certificate of the server installed on the Nextcloud server</li>
<li>The certificate is announced in the system&#8217;s LDAP configuration file (usually
<em>/etc/ldap/ldap.conf</em>)</li>
<li>Using LDAPS, also make sure that the port is correctly configured (by default
636)</li>
</ul>
</div>
<div class="section" id="microsoft-active-directory">
<h3>Microsoft Active Directory<a class="headerlink" href="#microsoft-active-directory" title="Permalink to this headline">¶</a></h3>
<p>Compared to earlier Nextcloud versions, no further tweaks need to be done to
make Nextcloud work with Active Directory. Nextcloud will automatically find the
correct configuration in the set-up process.</p>
</div>
<div class="section" id="memberof-read-memberof-permissions">
<h3>memberOf / read memberof permissions<a class="headerlink" href="#memberof-read-memberof-permissions" title="Permalink to this headline">¶</a></h3>
<p>If you want to use <code class="docutils literal"><span class="pre">memberOf</span></code> within your filter you might need to give your
querying user the permissions to use it. For Microsoft Active Directory this
is described <a class="reference external" href="https://serverfault.com/questions/167371/what-permissions-are-required-for-enumerating-users-groups-in-active-directory/167401#167401">here</a>.</p>
</div>
<div class="section" id="user-listing-and-login-per-nested-groups">
<h3>User listing and login per nested groups<a class="headerlink" href="#user-listing-and-login-per-nested-groups" title="Permalink to this headline">¶</a></h3>
<p>When it is intended to allow user listing and login based on a specific group
having subgroups (&#8220;nested groups&#8221;), checking <strong>Nested groups</strong> on <strong>Directory
Settings</strong> is not enough. Also the User (and Login) filter need to be changed,
by specifying the <code class="docutils literal"><span class="pre">LDAP_MATCHING_RULE_IN_CHAIN</span></code> matching rule. Change the
filter parts containing the <em>memberof</em> condition according to this example:</p>
<blockquote>
<div><ul class="simple">
<li>(memberof=cn=Nextcloud Users Group,ou=Groups,…)</li>
</ul>
</div></blockquote>
<p>to</p>
<blockquote>
<div><ul class="simple">
<li>(memberof:1.2.840.113556.1.4.1941:=cn=Nextcloud Users Group,ou=Groups,…)</li>
</ul>
</div></blockquote>
</div>
<div class="section" id="duplicating-server-configurations">
<h3>Duplicating server configurations<a class="headerlink" href="#duplicating-server-configurations" title="Permalink to this headline">¶</a></h3>
<p>In case you have a working configuration and want to create a similar one or
&#8220;snapshot&#8221; configurations before modifying them you can do the following:</p>
<ol class="arabic simple">
<li>Go to the <strong>Server</strong> tab</li>
<li>On <strong>Server Configuration</strong> choose <em>Add Server Configuration</em></li>
<li>Answer the question <em>Take over settings from recent server configuration?</em>
with <em>yes</em>.</li>
<li>(optional) Switch to <strong>Advanced</strong> tab and uncheck <strong>Configuration Active</strong>
in the <em>Connection Settings</em>, so the new configuration is not used on Save</li>
<li>Click on <strong>Save</strong></li>
</ol>
<p>Now you can modify and enable the configuration.</p>
</div>
<div class="section" id="sizelimit-exceeded-message-in-logs">
<h3>&#8220;Sizelimit exceeded&#8221; message in logs<a class="headerlink" href="#sizelimit-exceeded-message-in-logs" title="Permalink to this headline">¶</a></h3>
<blockquote>
<div>ldap_search(): Partial search results returned: Sizelimit exceeded at
apps/user_ldap/lib/LDAP.php#256</div></blockquote>
<p>This error message means one of the following:</p>
<ol class="arabic simple">
<li>Pagination of the results is used for communicating with the LDAP server
(pagination is by default enabled in OpenLDAP and AD), but there are more
results to return than what the pagination limit is set to. If there are no
users missing in you setup then you can ignore this error message for now.</li>
<li>No pagination is used and this indicates that there are more results on the
LDAP server than what is returned. You should then enabled pagination on
your LDAP server to import all available users.</li>
</ol>
</div>
</div>
<div class="section" id="nextcloud-ldap-internals">
<h2>Nextcloud LDAP internals<a class="headerlink" href="#nextcloud-ldap-internals" title="Permalink to this headline">¶</a></h2>
<p>Some parts of how the LDAP backend works are described here.</p>
<div class="section" id="user-and-group-mapping">
<h3>User and group mapping<a class="headerlink" href="#user-and-group-mapping" title="Permalink to this headline">¶</a></h3>
<p>In Nextcloud the user or group name is used to have all relevant information in
the database assigned. To work reliably a permanent internal user name and
group name is created and mapped to the LDAP DN and UUID. If the DN changes in
LDAP it will be detected, and there will be no conflicts.</p>
<p>Those mappings are done in the database table <code class="docutils literal"><span class="pre">ldap_user_mapping</span></code> and
<code class="docutils literal"><span class="pre">ldap_group_mapping</span></code>. The user name is also used for the user&#8217;s folder (except
if something else is specified in <em>User Home Folder Naming Rule</em>), which
contains files and meta data.</p>
<p>As of Nextcloud 5 the internal user name and a visible display name are separated.
This is not the case for group names, yet, i.e. a group name cannot be altered.</p>
<p>That means that your LDAP configuration should be good and ready before putting
it into production. The mapping tables are filled early, but as long as you are
testing, you can empty the tables any time. Do not do this in production.</p>
</div>
<div class="section" id="caching">
<h3>Caching<a class="headerlink" href="#caching" title="Permalink to this headline">¶</a></h3>
<p>The LDAP information is cached in Nextcloud memory cache, and you must install
and configure the memory cache (see
<a class="reference internal" href="../configuration_server/caching_configuration.html"><em>Configuring memory caching</em></a>). The Nextcloud  <strong>Cache</strong>
helps to speed up user interactions and sharing. It is populated on demand,
and remains populated until the <strong>Cache Time-To-Live</strong> for each unique request
expires. User logins are not cached, so if you need to improve login times set
up a slave LDAP server to share the load.</p>
<p>You can adjust the <strong>Cache Time-To-Live</strong> value to balance performance and
freshness of LDAP data. All LDAP requests will be cached for 10 minutes by
default, and you can alter this with the <strong>Cache Time-To-Live</strong> setting. The
cache answers each request that is identical to a previous request, within the
time-to-live of the original request, rather than hitting the LDAP server.</p>
<p>The <strong>Cache Time-To-Live</strong> is related to each single request. After a cache
entry expires there is no automatic trigger for re-populating the information,
as the cache is populated only by new requests, for example by opening the
User administration page, or searching in a sharing dialog.</p>
<p>There is one trigger which is automatically triggered by a certain background
job which keeps the <code class="docutils literal"><span class="pre">user-group-mappings</span></code> up-to-date, and always in cache.</p>
<p>Under normal circumstances, all users are never loaded at the same time.
Typically the loading of users happens while page results are generated, in
steps of 30 until the limit is reached or no results are left. For this to
work on an oC-Server and LDAP-Server, <strong>Paged Results</strong> must be supported.</p>
<p>Nextcloud remembers which user belongs to which LDAP-configuration. That means
each request will always be directed to the right server unless a user is
defunct, for example due to a server migration or unreachable server. In this
case the other servers will also receive the request.</p>
</div>
<div class="section" id="handling-with-backup-server">
<h3>Handling with backup server<a class="headerlink" href="#handling-with-backup-server" title="Permalink to this headline">¶</a></h3>
<p>When Nextcloud is not able to contact the main LDAP server, Nextcloud assumes it
is offline and will not try to connect again for the time specified in <strong>Cache
Time-To-Live</strong>. If you have a backup server configured Nextcloud will connect to
it instead. When you have scheduled downtime, check <strong>Disable Main Server</strong>  to
avoid unnecessary connection attempts.</p>
</div>
</div>
</div>


            
<ul class="prevnext-title list-unstyled list-inline">
  <li class="prev">
    <a href="user_auth_ftp_smb_imap.html" title="Previous Chapter: User authentication with IMAP, SMB, and FTP"><span class="glyphicon glyphicon-chevron-left visible-sm"></span><span class="hidden-sm">&laquo; User authentication with IMAP, SMB, and FTP</span>
    </a>
  </li>
  <li class="next">
    <a href="user_auth_ldap_cleanup.html" title="Next Chapter: LDAP user cleanup"><span class="glyphicon glyphicon-chevron-right visible-sm"></span><span class="hidden-sm">LDAP user cleanup &raquo;</span>
    </a>
  </li>
</ul>
					</div>
				</div>
			</div>
  </main>  
  </div>
</div>
  </body>
</html>