Remove all "FileHasObject" edge reads and writes
[phabricator.git] / src / applications / auth / management / PhabricatorAuthManagementLDAPWorkflow.php
blob2aa7aca16858bfa992300e032e5d54390c87eeaa
1 <?php
3 final class PhabricatorAuthManagementLDAPWorkflow
4 extends PhabricatorAuthManagementWorkflow {
6 protected function didConstruct() {
7 $this
8 ->setName('ldap')
9 ->setExamples('**ldap**')
10 ->setSynopsis(
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();
21 if (!$provider) {
22 $console->writeOut(
23 "%s\n",
24 pht('The LDAP authentication provider is not enabled.'));
25 exit(1);
28 if (!function_exists('ldap_connect')) {
29 $console->writeOut(
30 "%s\n",
31 pht('The LDAP extension is not enabled.'));
32 exit(1);
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();
60 if ($account_ids) {
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));
65 } else {
66 $console->writeOut("%s\n", pht('Unable to find LDAP account!'));
69 return 0;