Skip to content

Instantly share code, notes, and snippets.

@stevommmm
Last active August 29, 2015 13:57
Show Gist options
  • Select an option

  • Save stevommmm/9519118 to your computer and use it in GitHub Desktop.

Select an option

Save stevommmm/9519118 to your computer and use it in GitHub Desktop.
Remove ability to set passwords via authentication backends in OwnCloud
if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
$myClassReflection = new ReflectionClass(get_class(OC::$server->getUserManager()));
$secret = $myClassReflection->getProperty('backends');
$secret->setAccessible(true);
foreach($secret->getValue(OC::$server->getUserManager()) as $bkend) {
// var_dump($bkend);
$lclrefclass = new ReflectionClass($bkend);
$s = $lclrefclass->getProperty('possibleActions');
$s->setAccessible(true);
$pactions = $s->getValue($bkend);
if(($key = array_search('setPassword', $pactions)) !== false) {
unset($pactions[$key]);
}
OC_LOG::write('oc_otp', 'Backend password change before: ' . $bkend->implementsActions(OC_USER_BACKEND_SET_PASSWORD) ? 'enabled' : 'disabled', OC_Log::DEBUG);
$s->setValue($bkend, $pactions);
OC_LOG::write('oc_otp', 'Backend password change after: ' . $bkend->implementsActions(OC_USER_BACKEND_SET_PASSWORD) ? 'enabled' : 'disabled', OC_Log::DEBUG);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment