@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at upstream/main 72 lines 2.0 kB view raw
1<?php 2 3final class PhabricatorAuthManagementLDAPWorkflow 4 extends PhabricatorAuthManagementWorkflow { 5 6 protected function didConstruct() { 7 $this 8 ->setName('ldap') 9 ->setExamples('**ldap**') 10 ->setSynopsis( 11 pht('Analyze and diagnose issues with LDAP configuration.')); 12 } 13 14 public function execute(PhutilArgumentParser $args) { 15 $console = PhutilConsole::getConsole(); 16 $console->getServer()->setEnableLog(true); 17 18 PhabricatorLDAPAuthProvider::assertLDAPExtensionInstalled(); 19 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); 26 } 27 28 if (!function_exists('ldap_connect')) { 29 $console->writeOut( 30 "%s\n", 31 pht('The LDAP extension is not enabled.')); 32 exit(1); 33 } 34 35 $adapter = $provider->getAdapter(); 36 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.')); 42 } 43 44 phutil_passthru('stty -echo'); 45 $password = phutil_console_prompt(pht('LDAP Password: ')); 46 phutil_passthru('stty echo'); 47 48 if (!strlen($password)) { 49 throw new PhutilArgumentUsageException( 50 pht('You must enter an LDAP password.')); 51 } 52 53 $adapter->setLoginUsername($username); 54 $adapter->setLoginPassword(new PhutilOpaqueEnvelope($password)); 55 56 $console->writeOut("\n"); 57 $console->writeOut("%s\n", pht('Connecting to LDAP...')); 58 59 $account_ids = $adapter->getAccountIdentifiers(); 60 if ($account_ids) { 61 $value_list = mpull($account_ids, 'getIdentifierRaw'); 62 $value_list = implode(', ', $value_list); 63 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!')); 67 } 68 69 return 0; 70 } 71 72}