Skip to content

Commit

Permalink
Merge pull request #177 from Zeault/ldapi
Browse files Browse the repository at this point in the history
Add support and documentation for "ldapi://"  URI scheme
  • Loading branch information
jedisct1 authored Dec 9, 2024
2 parents 2bbe0f2 + 45af092 commit b916ad0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
6 changes: 5 additions & 1 deletion README.LDAP
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,13 @@ details anyway:

- LDAPScheme is the scheme (aka protocol) to connect with to the LDAP server.
It defaults to 'ldap'. To connect to a server listening on TLS port, set it
to 'ldaps' (and change the port below).
to 'ldaps' (and change the port below). To connect to a server listening on
a Unix domain socket, set it to 'ldapi'

- LDAPServer is the LDAP server name (hey!) . It defaults to 'localhost'.
If the 'ldapi' scheme is in use, this field should be set to the
*URL-encoded* path of the server socket. For example,
'/var/run/ldap.sock' becomes '%2Fvar%2Frun%2Fldap.sock'.

- LDAPPort is the connection port. It defaults to 389, the standard port.
Port value should be changed for 'ldaps' connection (the TLS port for an
Expand Down
14 changes: 11 additions & 3 deletions src/log_ldap.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,17 @@ void pw_ldap_parse(const char * const file)
if ((ldap_uri = malloc(sizeof_ldap_uri)) == NULL) {
die_mem();
}
snprintf(ldap_uri, sizeof_ldap_uri, "%s%s%s%s%s%d",
ldap_scheme, URI_SCHEME_SEPARATOR, URI_AUTHORITY_LEADER,
ldap_host, URI_PORT_LEADER, port);

/* The "ldapi://" scheme uri cannot contain a port number*/
if (pure_strcmp(ldap_scheme, "ldapi") == 0) {
snprintf(ldap_uri, sizeof_ldap_uri, "%s%s%s%s",
ldap_scheme, URI_SCHEME_SEPARATOR, URI_AUTHORITY_LEADER,
ldap_host);
} else {
snprintf(ldap_uri, sizeof_ldap_uri, "%s%s%s%s%s%d",
ldap_scheme, URI_SCHEME_SEPARATOR, URI_AUTHORITY_LEADER,
ldap_host, URI_PORT_LEADER, port);
}
}

/* Default to auth method bind, but for backward compatibility, if a binddn
Expand Down

0 comments on commit b916ad0

Please sign in to comment.