3 final class PhabricatorAuthManagementLDAPWorkflow
4 extends PhabricatorAuthManagementWorkflow
{
6 protected function didConstruct() {
9 ->setExamples('**ldap**')
11 pht('Analyze and diagnose issues with LDAP configuration.'));
14 public function execute(PhutilArgumentParser
$args) {
15 $console = PhutilConsole
::getConsole();
16 $console->getServer()->setEnableLog(true);
18 PhabricatorLDAPAuthProvider
::assertLDAPExtensionInstalled();
20 $provider = PhabricatorLDAPAuthProvider
::getLDAPProvider();
24 pht('The LDAP authentication provider is not enabled.'));
28 if (!function_exists('ldap_connect')) {
31 pht('The LDAP extension is not enabled.'));
35 $adapter = $provider->getAdapter();
37 $console->writeOut("%s\n", pht('Enter LDAP Credentials'));
38 $username = phutil_console_prompt(pht('LDAP Username: '));
39 if (!strlen($username)) {
40 throw new PhutilArgumentUsageException(
41 pht('You must enter an LDAP username.'));
44 phutil_passthru('stty -echo');
45 $password = phutil_console_prompt(pht('LDAP Password: '));
46 phutil_passthru('stty echo');
48 if (!strlen($password)) {
49 throw new PhutilArgumentUsageException(
50 pht('You must enter an LDAP password.'));
53 $adapter->setLoginUsername($username);
54 $adapter->setLoginPassword(new PhutilOpaqueEnvelope($password));
56 $console->writeOut("\n");
57 $console->writeOut("%s\n", pht('Connecting to LDAP...'));
59 $account_ids = $adapter->getAccountIdentifiers();
61 $value_list = mpull($account_ids, 'getIdentifierRaw');
62 $value_list = implode(', ', $value_list);
64 $console->writeOut("%s\n", pht('Found LDAP Account: %s', $value_list));
66 $console->writeOut("%s\n", pht('Unable to find LDAP account!'));