|
|
@@ -718,3 +718,53 @@ function zimbraSingle_ConfigOptions($params) {
|
|
|
);
|
|
|
return $configOptions;
|
|
|
}
|
|
|
+
|
|
|
+/**
|
|
|
+ * Perform single sign-on for a given instance of a product/service.
|
|
|
+ *
|
|
|
+ * Called when single sign-on is requested for an instance of a product/service.
|
|
|
+ *
|
|
|
+ * When successful, returns an URL to which the user should be redirected.
|
|
|
+ *
|
|
|
+ * @param array $params common module parameters
|
|
|
+ *
|
|
|
+ * @see https://developers.whmcs.com/provisioning-modules/module-parameters/
|
|
|
+ *
|
|
|
+ * @return array
|
|
|
+ */
|
|
|
+function zimbraSingle_ServiceSingleSignOn($params) {
|
|
|
+ $api = new Zm_Auth($params['serverhostname'], $params['serverusername'], $params['serverpassword'], 'admin');
|
|
|
+ $login = $api->login();
|
|
|
+ if(is_a($login, 'Exception')) {
|
|
|
+ logModuleCall(
|
|
|
+ 'zimbrasingle',
|
|
|
+ __FUNCTION__,
|
|
|
+ $params,
|
|
|
+ 'Error: cannot login to ' . $params['serverhostname'],
|
|
|
+ $login->getMessage()
|
|
|
+ );
|
|
|
+ return $login->getMessage();
|
|
|
+ }
|
|
|
+ $apiAccountManager = new Zm_Account($api);
|
|
|
+ $accountOptions = $apiAccountManager->getAccountOptions($params['username']);
|
|
|
+ if(is_a($accountOptions, 'Exception')) {
|
|
|
+ logModuleCall(
|
|
|
+ 'zimbrasingle',
|
|
|
+ __FUNCTION__,
|
|
|
+ $params,
|
|
|
+ 'Error : could not find quota for ' . $params['username'],
|
|
|
+ $accountOptions->getMessage()
|
|
|
+ );
|
|
|
+ }
|
|
|
+ logModuleCall(
|
|
|
+ 'zimbrasingle',
|
|
|
+ __FUNCTION__,
|
|
|
+ $params,
|
|
|
+ 'Debug',
|
|
|
+ $accountOptions
|
|
|
+ );
|
|
|
+ return array(
|
|
|
+ 'success' => true,
|
|
|
+ 'redirectTo' => 'https://testserver.test.local/',
|
|
|
+ );
|
|
|
+}
|