I'm no longer actively maintaining mod_ldap; it is orphaned. If you have some programming experience and would like to take over maintainership, I'd be happy to answer questions and provide initial guidance, and make all of the web site's content available.

mod_ldap is a module for ProFTPD that enables ProFTPD to do password/UID/GID lookups from an LDAP database. It is a mature, stable module. If you've successfully compiled and run mod_ldap please send me e-mail, I'd love to hear about it. Please note: if you submit a bug report or request for assistance, please please please include the following:


mod_ldap is distributed under the GPL, with an additional explicit clause to allow linking against OpenSSL.

Tested Platforms:

mod_ldap should build and run on just about any Unix or Unix-like platform. It is agnostic when it comes to LDAP servers and SDKs, so it should be able to link against and access just about anything you have.


- Fixed swapped DN/attr name interpolation in 'no attr for' error messages.
  (Bug #3776)
- %u is now interpolated in the LDAPDoQuotaLookups base DN, not just its
  search filter template. (Bug #3789)
- Fail explicitly when on/off is specified as the first argument to
  LDAPUsers or LDAPGroups.
- Don't emit the bind DN password in debug output when the bind is

- Prevent segmentation fault when no user filters (second and third
  arguments to LDAPUsers) are specified.

- Handle potential NULL return value from crypt(). (Bug #3551)
- Update README to mention the LDAPDNInfo -> LDAPBindDN change in v2.9.0.

- Overhaul configuration directives, hopefully yielding a more
  straightforward, easier way to configure mod_ldap. 

  The LDAPDoAuth and LDAPDoUIDLookups directives have been combined into the
  new LDAPUsers directive. The third argument to LDAPDoUIDLookups (the UID
  filter template) is now the third argument to LDAPUsers.

  LDAPDoGIDLookups is now LDAPGroups.

  LDAPDoQuotaLookups is now obsolete. The default quota can be specified
  with the new LDAPDefaultQuota directive.

  Also, the on/off booleans on these directives have been removed. Now, if
  the directive is present, the corresponding functionality will be enabled.

  For example, the previous configuration:

    LDAPDoAuth on ou=people,dc=horde,dc=net (uid=%u)
    LDAPDoUIDLookups on ou=people,dc=horde,dc=net (uidNumber=%u)
    LDAPDoGIDLookups on ou=groups,dc=horde,dc=net
    LDAPDoQuotaLookups on ou=people,dc=horde,dc=net (uid=%u) false,hard,10485760,0,0,0,0,0


    LDAPUsers ou=people,dc=horde,dc=net (uid=%u) (uidNumber=%u)
    LDAPGroups ou=groups,dc=horde,dc=net
    LDAPDefaultQuota false,hard,10485760,0,0,0,0,0

- Remove OpenSSL local verification of password hashes; 'LDAPAuthBinds on'
  should do exactly the same thing in a more secure and standard way.
- Remove deprecated LDAPNegativeCache and LDAPUseSSL directives.
- Add group members to debug output.
- Various internal improvements to comments, log/debug messages, style, and

* Add support needed by mod_sftp_ldap for fetching user public keys.
* Bad LDAP lookup can cause mod_ldap segfault under some conditions.
  (Bug #3424)

* Disable the LDAPUseSSL directive, instead logging a warning so existing
  configurations do not cause ProFTPD startup failure. Previous versions
  enabled TLS when this directive was enabled. This behavior was incorrect,
  since the intended behavior was to enable LDAPS/LDAP over SSL. To use
  LDAPS, specify the ldaps:// protocol in the LDAPServerURL URL(s).

  If you wish to continue using TLS, you must modify your configuration to
  specify the ldap:// scheme in the LDAPServerURL URL and add the directive
  'LDAPUseTLS on' to your configuration.
* Add support for quota profiles. If a user entry doesn't have an ftpQuota
  attribute, search for the DN contained in the user's ftpQuotaProfileDN
  attribute (if present) and use the ftpQuota attribute present on that DN.
  (Bug #2617)
* Fix segfaults in debug logging on platforms whose printf() does not
  gracefully handle NULL string pointers. (Bug #3346)
* Escape LDAP filter metacharacters in inserted values when interpolating
  filter templates.
* Emit a debug warning when an LDAP URL is specified without an explicit
  search scope.
* Bug 2922 locks authentication for an account to the same module that
  fetched the original account information. Remove the kludge wherein
  "*" is passed to pr_auth_check() if we're doing auth binds to prevent
  other modules from processing authentication. This has the convenient
  side effect of making the UserPassword directive work with LDAP-sourced
  accounts. Bump the required ProFTPD version to 1.3.1rc3. 
* Emit correct LDAP timeout in debug message, accounting for the default if
  none was specified. Reported by Nikos Voutsinas <nvoutsin@noc.uoa.gr>.

* Implement an internal failover mechanism instead of relying on the LDAP
  SDK's built-in failover (if any). Fixes failover regression introduced
  in v2.8.19 when ldap_initialize() was first used.
* Multiple LDAP URL arguments may now be passed to LDAPServer:

  LDAPServer ldap:// ldap://
* When setting whether to dereference LDAP aliases after connecting to
  the LDAP server, treat failure as a hard failure and refuse to continue
  with that LDAP server. Previously, failure when specifying whether to
  dereference aliases would be logged but the connection to that server
  would continue.

* Prevent the use of LDAPSearchScope or LDAPUseSSL when LDAPServer specifies
  a URL. Instead, the desired search scope and SSL setting should be
  specified by the URL.
* When using OpenSSL for local password verification (as opposed to
  'LDAPAuthBinds on'), make the Base64 encoding buffer larger to ensure
  we account for expansion resulting from the encoding.
* Retrieve all LDAP attributes when calling pr_ldap_user_lookup() since
  it will need various attributes (to perform home directory generation,
  for one). Thanks to Nikos Voutsinas <nvoutsin@noc.uoa.gr>.
* Portability fix: don't use ldap_initialize() and ldap_unbind_ext_s()
  unless we're building against the corresponding versions of the OpenLDAP

* Fix compilation with old LDAP SDKs (LDAP_API_VERSION < 2000). Thanks to
  Saju Paul <saju.paul@messageway.com>.
* Define LDAP_SCOPE_DEFAULT if not defined by the SDK, fixing compilation
  with (recent?) Sun LDAP headers.
* Use the configured ldap_port in "connected..." debug message, not
* Fix segfaults on client connect when an LDAP URL is used as an argument
  to the LDAPServer directive. (Bug #3097)
* Automatically enable LDAP TLS support based on a best guess as to whether
  the installed LDAP SDK supports it.
* Fixed missing ldap_init() -> ldap_initialize() when updating for latest
  LDAP C API. Fixes segfaults on (some?) 64-bit systems. (Bug #3046)

* Remove all local caching code in favor of the recently added caching in
  the ProFTPD Auth layer.
* Silence some compiler warnings.
* To verify non-crypt() password hashes locally with OpenSSL, it is no
  longer necessary to edit mod_ldap.c to enable HAVE_OPENSSL. Instead,
  build ProFTPD with the --enable-openssl argument to configure.

* Add 'LDAPAliasDereference never|search|find|always' directive, which
  defaults to never. This default is compatible with previous versions,
  which did not support alias dereferencing.
* Fix LDAPAttr support when more than one LDAPAttr directive is used.
* Sync with ProFTPD API: set session.auth_mech to indicate that we've
  successfully authenticated the user.
* Eliminate segfaults when group information for an LDAP user is available
  from other sources (such as mod_auth_unix). Thanks to Erick Briere
* Make sure to count %u escapes as well as %v escapes when determining
  filter length.
* Fix parenthesizing in connection code.

* Erroneous release; contained 2.8.14 by mistake.

* Fix authentication when LDAPAuthBinds is enabled, which broke in 2.8.13.
* Fix a typo in the group-by-name filter.

* This release REQUIRES ProFTPD 1.2.11rc1 or later.
* mod_ldap now uses ProFTPD's CreateHome to create home directories. Some
  LDAPHomedirOnDemand directives have been removed in favor of CreateHome.
  The directives that apply to home directory path name generation still
  exist, but have been renamed to LDAPGenerateHomedir.
* The LDAP protocol version now defaults to LDAPv3. If you need to use
  LDAPv2, say 'LDAPProtocolVersion 2' in your proftpd.conf. (Bug #2443)
* LDAP attribute names are now configurable via proftpd.conf. For example,
  if you want to change the uid attribute name, say 'LDAPAttr uid myUidAttr'
  in your proftpd.conf.
* The define to enable TLS support has been renamed to USE_LDAP_TLS.
* The '%u' escape is now supported in all cases where '%v' is.
* ProFTPD's UserPassword directive now works with LDAPAuthBinds enabled.
  (Bug #2482)
* Changed ldap_quota_lookup CMD to a HOOK.
* Fixed a few compiler type warnings.

* Group code memory manipulation fixes (Phil Oester (phil at theoesters dot
* Default quota support
* LDAP connections created for authenticated binds now honor the LDAPUseTLS

* mod_quotatab limit support
* Allow ATTR_* compiler defines to be overridden on the build command line,
  e.g.: CFLAGS="-DUID_ATTR=foo" ./configure
* The canonical username from the LDAP directory is now used in directory
* LDAPForceHomedirOnDemand to force the use of the generated home directory
  instead of the directory provided by the LDAP directory.
* Support for permissions on LDAPHomedirOnDemand suffixes. You can say:

  LDAPHomedirOnDemandSuffix foo:755 bar:700

  in your proftpd.conf.
* Support for %v escapes in LDAPDoAuth directive to allow fetching the
  user's entry directly, without performing a search first. For example,

  LDAPDoAuth on uid=%v,dc=example,dc=com

  will fetch the entry uid=[username],dc=example,dc=com directly when a user
  logs in, saving some effort on the part of the LDAP directory.
* Leading directories are now checked for and creation is no longer
  attempted if they already exist.
* Miscellaneous pedanticism & cleanup in error messages and the code itself.

* Ditch ldap_build_filter() (non-portable and/or deprecated) in favor of
  our own translation function. This should make mod_ldap build against
  OpenLDAP 2.1.x and Novell eDirectory, among others.

* Added explicit OpenSSL link exception to the license.

* ProFTPD Bug 1659 - LDAP config handlers should use c->pool instead of

* Properly drop root privs in the LDAPHomedirOnDemand code if we're
  returning prematurely due to an error condition.
* Small cleanup of the LDAPHomedirOnDemand directory creation code.

* Fix to the user-caching code that now prevents the cache from
  returning an empty password struct in certain situations.

* Small fix in the group handlers - group lookups would sometimes be
  attempted even if they were disabled.

* Fix for segfaults when optional arguments are omitted from
  LDAPDoGIDLookups directive

* Secondary group support (thanks to Andreas Strodl for providing patches)
* LDAPHomedirOnDemand modes are now absolute; they are no longer subject
  to ProFTPD's umask.
* LDAPDefault[UG]ID directives should now support the full range of
  32-bit UIDs.
* Sanity checking is now done on LDAPDefault[UG]ID arguments to ensure
  they're numeric.
* LDAPDoGIDLookups now takes an extra argument. Its arguments are now:

  LDAPDoGIDLookups on|off group-base-dn by-name-filter by-uid-filter

  by-name-filter defaults to (&(cn=%v)(objectclass=posixGroup)) and
  by-uid-filter defaults to (&(gidNumber=%v)(objectclass=posixGroup)).

* Fixed a privilege escalation bug. If LDAPHomedirOnDemand is enabled and
  creation of the user's home directory fails, the server does not
  relinquish root privileges. There shouldn't be exploitable, but all
  users with LDAPHomedirOnDemand enabled are encouraged to upgrade.

* Fixed a bug that prevented proper permissions being applied to home
  directories created on demand.
* Fixed an issue that would prevent per-VirtualHost configuration directives
  from being properly recognized.

* The username escape sequence in search filter templates has changed.
  You must now use %v instead of %u as the escape for the username. For
  example, if you had:

    LDAPDoAuth on dc=example,dc=com (uid=%u)

  in your proftpd.conf with a previous version of mod_ldap, you will need
  to change this to:

    LDAPDoAuth on dc=example,dc=com (uid=%v)

* LDAPAuthBinds is now enabled by default. I'm sick of hearing "Your
  mod_ldap is broken; it won't talk to my LDAP server and I've ignored the
  convenient error message about userPassword that mod_ldap logs."

* The full path to user home directories is now created. Directories leading
  up to the user's home directory are created root-owned and mode 755 (i.e.,
  they are not subject to the mode argument to LDAPHomedirOnDemand). Home
  directory creation now works for all users, not just users with the same
  UID/GID as the main ProFTPD server. Lastly, the mode argument to
  LDAPHomedirOnDemand is no longer subject to ProFTPD's Umask.

* TLS support (You'll need to edit mod_ldap.c to define USE_LDAPV3_TLS and
  recompile proftpd, then say 'LDAPUseTLS on' in your proftpd.conf). This
  may or may not work with non-OpenLDAP SDKs; I'd love to hear if anyone has
  it working with the Mozilla LDAP SDK or any others.

* The LDAP search sizelimit is now set to prevent LDAP server thrashing with
  wildcarded usernames.

* Basic caching support has been added. This should cut down on the number
  of queries made to the directory server. In addition, negative caching
  is now enabled by default.

* LDAPHomedirOnDemandSuffix can now take multiple arguments (multiple
  directories to create) and can be activated independently of

* With the addition of LDAPHomedirOnDemandPrefix, home directories can now
  be completely autogenerated, removing the need for a homeDirectory
  attribute in each user's LDAP entry. Say:

    LDAPHomedirOnDemandPrefix /home

  in your proftpd.conf to give users a home directory with the format
  /home/username. In this example, the user joe would be given the home
  directory /home/joe.

* Attribute names are now #defines at the top of mod_ldap.c. You can now
  change attribute names by editing mod_ldap.c and recompiling.

* The LDAPDefaultUID and LDAPDefaultGID directives can now be forced;
  enabling LDAPForceDefaultUID or LDAPForceDefaultGID will apply the
  default UID or GID (respectively) even if a user has a different UID/GID
  in his uidNumber or gidNumber attribute.

* Fairly extensive code cleanup and comment syncing.

* Fixing the OpenLDAP 2 fixes.

* Fixes for OpenLDAP 2 support.
* Fix LDAP authentication filter use; previously, the user-specified search
  filter would not be used in the second stage of authenticating a user.

* The LDAPDefaultAuthScheme directive should function properly now.

* Removed some old, useless code.

* LDAPQueryTimeout fix. In mod_ldap v2.7.1, in some situations, the query
  timeout could be set to -1, which would cause all LDAP lookups to fail.

* Ported MacGyver's portable UID/GID code to mod_ldap
* The value passed to LDAPQueryTimeout is now honored (the timeout isn't
  simply set to 1 second)

* Added a fix for picky LDAP servers like Sun Directory Services; using
  AuthBinds with those LDAP servers would break in previous mod_ldap
  versions.  See the comments in the code for more details (search for "Sun
  Directory Services").
* You can now pass a file mode to LDAPHomedirOnDemand to create home
  directories with that mode.
* Improved group support; mod_ldap now supports multiple memberUid
  attributes for a group object.
* Miscellaneous neatening/tightening of high-level auth/lookup handler
* You can now specify custom LDAP search filters at runtime. See the
  configuration guide (doc/Configuration.html) entries for LDAPDo* for more
* Objectclass is now enforced. You *must* have an objectclass attribute for
  each of your LDAP objects. This attribute must have a value of
  'posixAccount' ("objectclass: posixAccount"). For groups, this attribute
  must have the value 'posixGroup' ("objectclass: posixGroup"). If you wish
  to disable this objectclass enforcement, use the the LDAP filter
  "(uid=%u)" for Auth and UID lookups (see doc/Configuration.html for how to
  specify a custom LDAP search filter).
* Removed allowedServices code. The functionality that allowedServices
  provided can now be duplicated with a modified LDAP search filter.

  For example, to replicate basic allowedServices checking, pass this LDAP
  search filter to LDAPDoAuth:

  To emulate deniedServices checking, use this search filter:

  To emulate *both* allowedServices and deniedServices checking, use this

* Fixed a bug that would prevent proper search scope selection.

* HomedirOnDemandSuffix - create an additional subdirectory in a user's home
  directory (/home/user/anotherdirectory) on demand
* Minor group fixes/cleanups - supplementary groups now work properly
* Password {scheme}s are now treated in a case-insensitive manner.
* Password-hash support for any crypto method OpenSSL supports
  To enable extended OpenSSL password hash support, edit mod_ldap.c and
  uncomment #define HAVE_OPENSSL. You'll also need to edit Make.rules to
  link against OpenSSL. Further details are provided in mod_ldap.c.
* Runtime search scope selection; one-level or subtree searches can be
  selected from proftpd.conf.

* Fixed a bug that would allow unauthorized users to log in when mod_ldap
  is used with other authentication modules and LDAPAuthBinds is set to on.

* Fixed a one-line bug that broke password authentication when AuthBinds
  weren't being used.

* Authenticated bind support added. mod_ldap now fetches all user information
  except for userPassword as the DN specified in LDAPDNInfo and then re-binds
  to the LDAP server as the connecting user with the user-supplied password.
  If the bind succeeds, the user is allowed to log in. This also has the
  added advantage of allowing mod_ldap to support any password encryption
  scheme that your LDAP server supports. Also, a privileged DN is no longer
  needed to read the userPassword attribute from the LDAP server.
* Realized I wasn't checking the return value of find_config() for NULL
  values, this would cause ProFTPD to segfault if certain config file
  entries were not present.
* Removed debugging code that might contain NULL values; passing a NULL
  value to printf() and friends under Solaris causes a segfault.
* Miscellaneous cleanups, code neatening.

* config file syntax revamped:
   LDAPServer            localhost
   LDAPDNInfo            cn=your-dn,dc=horde,dc=net dnpass
   LDAPQueryTimeout      5
   LDAPDoAuth            on "dc=horde,dc=net"
   LDAPDoUIDLookups      on "dc=horde,dc=net"
   LDAPDoGIDLookups      on "dc=horde,dc=net"
   LDAPDefaultUID        35000
   LDAPDefaultGID        1000
   LDAPNegativeCache     on
   LDAPHomedirOnDemand   on
   LDAPDefaultAuthScheme clear
* query timeout implemented
* clear password "encryption" scheme implemented
* group lookups
* separate prefixes for user and group lookups
* can turn on/off user/group lookups independently of each other
* default [ug]ids. say you want to have a web-toaster type of deal, with
  all users having the same [ug]ids. just don't put [ug]idNumber attrs 
  in your ldap db for those users, and set either of these two config
  directives. any user that doesn't have a [ug]id in the ldap database  
  will have that info filled in with the default [ug]id.
* allowedServices attr: (i broke with objectclass here, couldn't find
  something that seemed to fit this.) comma-separated list of services to 
  allow for this particular user. say you want to enable ftp access for
  a user, but not www service. set the allowedServices attr for that  
  particular user to "FTP" and www service will be denied. basically, 
  if the string FTP is listed in this attr, ftp access will be allowed.  
* query timeout config file directive added
* you can have alternate ldap servers; just specify LDAPServer "host1
  host2"; thanks to Peter Deacon (peterd at iea-software dot com) for
  pointing this out.
* clear authentication scheme. some ldap servers support {clear} for
  no password encryption.

* made the variables for the config entries static
* moved the meat of the ldap querying code to a separate function, this
  gets the individual getpw*() handlers down to about 15-20 lines each.
  also paves the way for easy LDAP group lookups too.
* explicitly set ld = NULL in p_endpwent(), looks like ldap_unbind()
  doesn't always set it to NULL, and bad things happen later.
* fixed a showstopper: if there's a user/group directive in proftpd.conf,
  mod_ldap:getpwnam() will be called to look up the user. since the
  LDAP config variables aren't initialized yet, the LDAP libraries crash
  and burn upon encountering a NULL ldap_prefix. put some checks in
  p_setpwent() to check for this and disable LDAP lookups before the
  parent forks and the config is initialized. thanks to Sean Murphy
  (smurphy at berbee dot com) for sending me on this path.
* modified pw_auth() so that it will assume crypt() if there's no leading
  {scheme} in the password returned by the LDAP query.
* pw_auth() turned off logging of unidentifiable password encryption
  schemes; this would syslog the encrypted password returned by the ldap
  server. many people have their logs tightened, but not all.
* a few miscellaneous changes & cleanups

* Added $Libraries$ directive to mod_ldap so the module is now entirely
* Changed one reference to sprintf() to snprintf() and changed uidstr
  in p_getpwuid() to have a length of BUFSIZ.
* Added config option (LDAPNegativeCache) to turn LDAP negative caching
  on and off. The default is off (don't do LDAP negative caching).
* Added entries to doc/Configuration.html for all the LDAP configuration
* MacGyver added mod_ldap to the ProFTPD CVS tree; mod_ldap-1.1
  is now in sync with ProFTPD CVS.

* Initial release of mod_ldap


If you are using a version of mod_ldap included with a ProFTPD release, you can simply:

If you wish to use a newer version of mod_ldap that is not yet included with a release version of ProFTPD, simply download the file mod_ldap.c, say:

and then follow the same steps as above.

Current Release

The mod_ldap source repository is also available.

Previous Relases


If you've pointed a bug out to me, submitted code or assisted in mod_ldap development in some way or another, you should be here! If you're not, please send me an e-mail; I'll be glad to add you.

last update: