LDAP Server and Active Directory
If you use the default installation of webPDF, the users found in the conf/users.xml XML database are used for authentication. It is also possible to use the users from an LDAP or Active Directory (AD) service.
In the current version, you can set an LDAP or AD service via the Admin Portal under Portal > User source.
Use the Admin Portal to configure the user source whenever possible. The following explanations under Manual configuration can help when entering the values in the portal, but manual editing of conf/server.xml should normally only be used for recovery if the Admin Portal is not accessible.
Use the Test button in the Portal > User source dialog to validate the LDAP connection, bind settings, and lookup configuration before saving the changes.
Manual configuration
The user database can be modified by changing the settings in conf/server.xml.
If possible, use the Admin Portal of the server to change the user database.
To take the users from an LDAP server or Active Directory, you must add the entry <ldap> to the <user>. Below is an example of a complete configuration of LDAP settings.
Please note that some of the configuration settings have to be specified as "Distinguished Names". This is especially the case when LDAP or AD objects have to be referenced.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<server xmlns="http://schema.webpdf.de/1.0/configuration/server">
...
<user roleAdminGroup="webPDFAdmin" roleUserGroup="webPDFUser">
<ldap connectionName="cn=ldapuser,cn=Users,dc=example,dc=local"
connectionPassword="my_password"
connectionURL="ldap://server.example.com:389/"
roleBase="CN=Users,DC=example,DC=local"
roleField="cn"
roleSearch="(member={0})"
userBase="CN=Users,DC=example,DC=local"
userSearch="(sAMAccountName={0})"/>
</user>
...
</server>
After making this modification, you must configure the access to the LDAP server or the Active Directory. For this purpose, adjust the values in the example above to match your configuration. In the example, example.com is used as the domain. Change the values accordingly to those of your own domain.
Basically, you need to adjust the server name and domain in the connectionURL entry. In this example they are shown as server and example.com.
Note that ldap:// must be replaced with ldaps:// if you want to use an TLS connection to the LDAP server. As a rule, the port must also be changed from 389 to 636.
Under the entries connectionName and connectionPassword please enter a user and the associated password to be used for accessing the LDAP or AD server.
If no user is required for LDAP access, then these settings can be left empty.
userBase and userSearch define the basis on which the directory search is to take place and how the login name for the user is to be found. userBase provides the list of users (objects) in which userSearch is used to search for the login name of the user. The wildcard {0} is replaced by the login name of the user during evaluation of the query. In the previously listed example, CN=Users,DC=example,DC=local and (sAMAccountName={0}) are typical values for a search in an Active Directory used as LDAP. You may need to modify these values to match the structure of your directory service.
Example: (sAMAccountName=jdo) (with jdo as login name for user "John Doe")
Once the user is found, the "Distinguished Name" (DN) is taken from the user object (attribute distinguishedName) and used to find the matching group.
Example: distinguishedName: CN=John Doe,CN=Users,DC=example,DC=local
The roleBase and roleSearch settings are used to search for the group. While roleBase is the base for the search, roleSearch is used to find all groups that have the previously determined DN as an attribute. The placeholder {0} in roleSearch is replaced with the DN.
Example: (member=CN=John Doe,CN=Users,DC=example,DC=local)
In all found groups the attribute defined via roleField is read (in this example cn). If the value that was read, i.e. the name of the group, matches user and admin, then the corresponding permission role (webPDF group) is assigned:
user- Access authorization as a normal useradmin- Access authorization as administrator (access to the Admin Portal)
For more information about the groups, see User groups.
With the entries roleAdminGroup and roleUserGroup you define your own group names (LDAP and AD groups respectively) to be assigned to the webPDF groups user and admin. Change the group names to the names of your LDAP or AD groups:
Example: Use LDAP group webPDFAdmin (roleAdminGroup) for webPDF group admin and webPDFUser (roleUserGroup) for user.
<user roleAdminGroup="webPDFAdmin" roleUserGroup="webPDFUser">
Users who need administrator access should also be members of the group configured via roleUserGroup. Otherwise, they may be able to authenticate but still receive WEBSERVICE_AUTHORIZATION_NO_USER_ROLE (-86) because their authorization does not include the required user role.
Securing the connection
Two settings harden how the server talks to the directory service. Both are switched off by default in this version, so an existing installation keeps behaving exactly as before; switch them on deliberately.
In the Admin Portal, both are set under Portal > User source for an LDAP user source: Verify host name on the
Connection tab, below Certificates trust mode, and Follow referral together with the referral policy on the
Referrals tab. The policy fields are only shown while Follow referral is switched on.
Encryption and the identity of the server
certificatesTrustMode decides whether the certificate chain presented by the LDAP server is trusted;
verifyHostName decides whether that certificate actually belongs to the host you configured. These are
two separate questions, and answering only the first is not enough: without the host name check, any
certificate the trust mode accepts will do, including one issued for an entirely different domain. An
attacker on the internal network then only needs a regularly issued certificate of their own to terminate the
ldaps:// connection, collect the bind of the LDAP service account and read every user password that passes
through it.
<ldap connectionURL="ldaps://server.example.com:636"
certificatesTrustMode="validate"
verifyHostName="true"
... />
| Setting | Default | Effect |
|---|---|---|
certificatesTrustMode="validate" | yes | Only a certificate whose chain can be verified is trusted. Place the issuer certificate in the server truststore if it is not publicly known. |
certificatesTrustMode="acceptAll" | – | Every certificate is trusted, including expired, invalid and self-signed ones. The host name is then not verified either, and the server writes a warning to the log. |
verifyHostName="true" | – | The certificate has to name the host from connectionURL. |
verifyHostName="false" | yes | The host name is not checked. The server writes a warning to the log for encrypted connections. |
The host name is matched against the subject alternative names of the certificate (DNS, URI and IP entries)
and against the common name of its subject; wildcard names such as *.example.com are accepted. A
certificate without a matching entry is rejected.
A connection to a loopback address (for example ldaps://127.0.0.1) is exempt from the check and is
accepted without a matching certificate entry. A loopback connection cannot be redirected by anyone on the
network, so there is no identity left to verify. The host name localhost is not covered by the
exception and is matched normally.
Before switching verifyHostName on, verify that the certificate of your LDAP server names the host you
configured. If it does not, the connection fails and the server does not start; the log then names
verifyHostName as a possible cause.
Where a referral may lead
When followReferral="true", the server follows references that the directory service returns — and it binds
to the referred host with the same service account credentials. The target is chosen by the directory, not
by you, so a compromised or misconfigured directory can point the server at an arbitrary host and collect
those credentials. referralPolicy bounds where a referral may lead.
<ldap connectionURL="ldaps://dc1.example.com:636" followReferral="true" ... >
<referralPolicy restrictToSameHost="true"
allowedHosts="dc2.example.com,.branch.example.com"
deniedHosts=""
maxHops="5"/>
</ldap>
| Attribute | Default | Effect |
|---|---|---|
restrictToSameHost | false | When true, a referral may only lead to the host of connectionURL or to a host in allowedHosts. |
allowedHosts | empty | Comma-separated list of additionally permitted hosts. An entry starting with a dot (.example.com) matches the domain and all of its sub-domains; every other entry is matched exactly. A leading * is not a wildcard. |
deniedHosts | empty | Comma-separated list of hosts that are never contacted. A denied host is rejected even when it is also allowed. |
maxHops | library default | Maximum number of referrals followed for one request. Only applied when set. |
A target is evaluated in a fixed order: denied hosts first, then a referral that would move an encrypted connection to an unencrypted one, then the allow list, and finally the same-host restriction. Every rejected referral is written to the log with its target and the reason.
In an Active Directory forest a referral regularly points at a different domain controller. With
restrictToSameHost="true" such a referral is rejected, the referred user is not found, and the login fails.
If you use followReferral="true" across several hosts, list them in allowedHosts — the log names each
rejected target.
IP addresses may be used in both lists and are compared as addresses, so alternative notations of the same
address match the same entry. The lists are host based: a directory service that also controls DNS can point
a name that is not denied at an address that is, which is why restrictToSameHost is the primary control and
the deny list an addition.
The scheme of a referral URL is now honoured
Previously the scheme of a referral URL was ignored: whether the referred connection used TLS depended only
on whether the base connection had already created one. A referral that declared ldaps:// was therefore
opened in the clear, and a referral that declared ldap:// was opened encrypted. Both are corrected — the
scheme of the referral URL now decides.
One consequence is worth knowing before you upgrade: a directory service that returns ldap://host:636, that
is a URL declaring the unencrypted protocol on a port that only serves TLS, used to work by accident and is
now rejected with a log entry. Such a referral URL is misconfigured; correct it to ldaps://host:636.
The settings on this page can also be supplied from the environment by using a placeholder in
conf/server.xml, for example verifyHostName="${WEBPDF_LDAP_VERIFY_HOST_NAME:-false}".
Troubleshooting
Admin Portal login is not possible
LDAP and AD user passwords are managed in the directory service, not in webPDF. If a directory user's password is forgotten, reset it in LDAP or Active Directory.
If LDAP or AD settings prevent access to the Admin Portal, or if no directory administrator can currently sign in to webPDF, manually edit conf/server.xml and restore the local XML user source:
<user>
<xml/>
</user>
This switches the server back to the local conf/users.xml user database. Restart the webPDF server after saving the file so the change takes effect. For file locations on Windows and Linux, see Directories.
Before manually editing conf/server.xml, create a backup copy of the file. Manual editing should only be used as a recovery step when the Admin Portal is not accessible.
After the restart, sign in with an administrator from conf/users.xml. If no working local administrator is available, restore the default administrator first as described in XML Database troubleshooting.
Once access to the Admin Portal has been restored, correct the LDAP or AD settings under Portal > User source. Use the Test button before saving the external user source again.
Login works, but the user still has no access to the portal or web services
If authentication succeeds but the user cannot use the portal or API, verify that the LDAP or AD user is assigned to the group configured by roleUserGroup.
If the user should also have administrator permissions, verify that the same user is a member of both configured groups:
<user roleAdminGroup="webPDFAdmin" roleUserGroup="webPDFUser">
An administrator must be mapped to both the admin role and the user role.
The LDAP connection cannot be established
Review the connection settings first:
- Confirm that
connectionURLuses the correct host name, protocol, and port. - Use
ldap://with port389for non-TLS connections. - Use
ldaps://with port636for TLS-secured connections. - If
ldaps://is used, verify that the LDAP server certificate chain is trusted by the server environment. - If
ldaps://is used together withverifyHostName="true", verify that the certificate also names the host fromconnectionURL. The server logs a corresponding hint when the connection fails; see Encryption and the identity of the server.
Users behind a referral are no longer found
With followReferral="true" and restrictToSameHost="true", a referral to a different host is rejected. This
is the common case in an Active Directory forest, where a referral points at another domain controller. The
server logs every rejected target and the reason; add those hosts to referralPolicy allowedHosts, see
Where a referral may lead.
Also verify connectionName and connectionPassword. Leave them empty only if anonymous LDAP access is allowed by your directory service.
The user can be found, but no groups are mapped
If user authentication succeeds but no roles are assigned, review the group lookup settings:
- Verify that
roleBasepoints to the correct container or organizational unit for groups. - Verify that
roleSearch="(member={0})"matches how your directory stores group membership. - Verify that
roleFieldreturns the actual group name to compare withroleAdminGroupandroleUserGroup. - If your directory uses nested groups, check whether the configured LDAP query can resolve those memberships.
The login name is not found
Review the user lookup settings:
- Verify that
userBasepoints to the correct container or organizational unit for users. - Verify that
userSearchuses the correct login attribute for your directory, for examplesAMAccountNamein many Active Directory environments oruidin other LDAP directories.
If necessary, compare the configured search attributes with a known working user entry in your directory.
Check the server logs
If the configuration still does not work, inspect the server logs for LDAP bind errors, TLS or certificate problems, and failed user or group searches. These messages are usually the fastest way to distinguish between connection, search base, and role mapping issues.
If you are using the Admin Portal, run the built-in Test first so you can confirm the configuration before moving on to manual diagnostics.
Linux command line diagnostics
If webPDF runs on Linux, command line tools can help identify whether the problem is caused by DNS resolution, network connectivity, TLS, LDAP bind credentials, or LDAP search filters.
The examples below use common Linux tools. Package names may differ slightly between distributions.
Install the required tools
Install the tools that match your Linux distribution:
- Ubuntu or Debian:
sudo apt install ldap-utils openssl dnsutils netcat-openbsd - RHEL, Rocky Linux, AlmaLinux, or CentOS:
sudo dnf install openldap-clients openssl bind-utils nmap-ncat - SUSE Linux Enterprise Server or openSUSE:
sudo zypper install openldap2-client openssl bind-utils netcat-openbsd
tcpdump can also be useful for low-level network diagnostics if packet capture is allowed in your environment.
Check DNS resolution
Verify that the LDAP host name resolves correctly from the webPDF server:
host server.example.com
dig server.example.com
If the host cannot be resolved, fix DNS or use a reachable host name or IP address in connectionURL.
Check network connectivity
Verify that the LDAP or LDAPS port is reachable:
nc -vz server.example.com 389
nc -vz server.example.com 636
If the connection fails, check routing, firewall rules, container network policies, and whether the LDAP server is listening on the expected port.
Check the TLS handshake for LDAPS
When ldaps:// is used, verify that the TLS handshake and certificate chain are valid:
openssl s_client -connect server.example.com:636 -showcerts
If the handshake fails or the certificate is not trusted, review the LDAP server certificate chain and the trust configuration of the server environment.
Check LDAP bind and user lookup
Use ldapsearch to verify that the configured bind account can connect and that the user search returns the expected entry:
ldapsearch -x -H ldap://server.example.com:389 \
-D "cn=ldapuser,cn=Users,dc=example,dc=local" -W \
-b "CN=Users,DC=example,DC=local" \
"(sAMAccountName=jdo)"
This helps confirm that connectionURL, connectionName, connectionPassword, userBase, and userSearch are correct.
Check LDAP group lookup
Use ldapsearch again to confirm that the group search returns the groups used by roleAdminGroup and roleUserGroup:
ldapsearch -x -H ldap://server.example.com:389 \
-D "cn=ldapuser,cn=Users,dc=example,dc=local" -W \
-b "CN=Users,DC=example,DC=local" \
"(member=CN=John Doe,CN=Users,DC=example,DC=local)"
This helps confirm that roleBase, roleSearch, and roleField match your directory structure.
Inspect active connections
If requests appear to hang or time out, inspect active TCP connections on the server:
ss -tan | grep ':389\|:636'
This can help determine whether connections are established, stuck during handshake, or immediately closed.
After all modifications have been made, the webPDF server must be restarted so that all the settings take effect and the users are read.