Differential D9431 Diff 22523 src/applications/auth/management/PhabricatorAuthManagementLDAPWorkflow.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/auth/management/PhabricatorAuthManagementLDAPWorkflow.php
| Show All 13 Lines | final class PhabricatorAuthManagementLDAPWorkflow | ||||
| public function execute(PhutilArgumentParser $args) { | public function execute(PhutilArgumentParser $args) { | ||||
| $console = PhutilConsole::getConsole(); | $console = PhutilConsole::getConsole(); | ||||
| $console->getServer()->setEnableLog(true); | $console->getServer()->setEnableLog(true); | ||||
| $provider = PhabricatorAuthProviderLDAP::getLDAPProvider(); | $provider = PhabricatorAuthProviderLDAP::getLDAPProvider(); | ||||
| if (!$provider) { | if (!$provider) { | ||||
| $console->writeOut( | $console->writeOut( | ||||
| "%s\n", | "%s\n", | ||||
| "The LDAP authentication provider is not enabled."); | 'The LDAP authentication provider is not enabled.'); | ||||
| exit(1); | exit(1); | ||||
| } | } | ||||
| if (!function_exists('ldap_connect')) { | if (!function_exists('ldap_connect')) { | ||||
| $console->writeOut( | $console->writeOut( | ||||
| "%s\n", | "%s\n", | ||||
| "The LDAP extension is not enabled."); | 'The LDAP extension is not enabled.'); | ||||
| exit(1); | exit(1); | ||||
| } | } | ||||
| $adapter = $provider->getAdapter(); | $adapter = $provider->getAdapter(); | ||||
| $console->writeOut("%s\n", pht('Enter LDAP Credentials')); | $console->writeOut("%s\n", pht('Enter LDAP Credentials')); | ||||
| $username = phutil_console_prompt("LDAP Username: "); | $username = phutil_console_prompt('LDAP Username: '); | ||||
| if (!strlen($username)) { | if (!strlen($username)) { | ||||
| throw new PhutilArgumentUsageException( | throw new PhutilArgumentUsageException( | ||||
| pht("You must enter an LDAP username.")); | pht('You must enter an LDAP username.')); | ||||
| } | } | ||||
| phutil_passthru('stty -echo'); | phutil_passthru('stty -echo'); | ||||
| $password = phutil_console_prompt("LDAP Password: "); | $password = phutil_console_prompt('LDAP Password: '); | ||||
| phutil_passthru('stty echo'); | phutil_passthru('stty echo'); | ||||
| if (!strlen($password)) { | if (!strlen($password)) { | ||||
| throw new PhutilArgumentUsageException( | throw new PhutilArgumentUsageException( | ||||
| pht("You must enter an LDAP password.")); | pht('You must enter an LDAP password.')); | ||||
| } | } | ||||
| $adapter->setLoginUsername($username); | $adapter->setLoginUsername($username); | ||||
| $adapter->setLoginPassword(new PhutilOpaqueEnvelope($password)); | $adapter->setLoginPassword(new PhutilOpaqueEnvelope($password)); | ||||
| $console->writeOut("\n"); | $console->writeOut("\n"); | ||||
| $console->writeOut("%s\n", pht('Connecting to LDAP...')); | $console->writeOut("%s\n", pht('Connecting to LDAP...')); | ||||
| Show All 11 Lines | |||||