Skip to content

Commit d1f4546

Browse files
committed
Check for the required PHP-LDAP functions.
1 parent d9ed4f5 commit d1f4546

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ Requirements for running this tool from a management station:
3333

3434
* Any system that can run PHP-CLI will do. (Even Windows.)
3535
* [PHP](https://www.php.net) version 7.0 or later: Available to most Linux distributions via `apt-get` or `yum`. You don't need anything web related, but you will need the command line interface.
36+
* [PHP's LDAP functions](http://php.net/manual/en/book.ldap.php): Usually installed with PHP as standard, but the LDAP module/functions may not be enabled by default.
3637
* [Composer](https://getcomposer.org/): Available to most Linux distributions via `apt-get` or `yum`, or manually download it as `composer.phar` alongside this tool.
37-
* LDAP instance: Used for Gitlab's authentication. It can (likely) be Microsoft Active Directory, OpenLDAP, 389-DS (including FreeIPA), and likely any other LDAP system, though **most of my testing is using a 389-DS instance**.
38+
* LDAP instance: Used for Gitlab's authentication. It can (likely) be Microsoft Active Directory, OpenLDAP, 389-DS (including FreeIPA), and any other LDAP system, though **most of my testing is with 389-DS (without FreeIPA)**.
3839
* [Gitlab community edition](https://gitlab.com/gitlab-org/gitlab-ce/): This must be configured to authenticate against an LDAP instance already.
3940

4041
## Installing

src/LdapSyncCommand.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,21 @@ public function execute(InputInterface $input, OutputInterface $output): ?int
4848
$this->logger->warning("Dry run enabled: No changes will be persisted.");
4949
}
5050

51+
foreach([
52+
"ldap_connect",
53+
"ldap_bind",
54+
"ldap_set_option",
55+
"ldap_errno",
56+
"ldap_error",
57+
"ldap_search",
58+
"ldap_get_entries",
59+
] as $ldapFunction) {
60+
if (!function_exists($ldapFunction)) {
61+
$this->logger->critical(sprintf("PHP-LDAP function \"%s\" does not exist.", $ldapFunction));
62+
return 1;
63+
}
64+
}
65+
5166

5267

5368
// Load configuration

0 commit comments

Comments
 (0)