Jump to content

Custom LDAP Hook Not Working with v8


zooky

Recommended Posts

Hey All,

I have a custom LDAP hook for WHMCS which creates a user on a LDAP server when a new customer signs up.

After upgrading to WHMCS v8, it seems the hook "create" function is not working.  Below is a bit from Module Debug Log

Action = hook_ldapsync_createuser

Request: 

Array
(
    [client_id] => 5114
    [user_id] => 5144
    [userid] => 5114
    [firstname] => Test
    [lastname] => Testing
    [companyname] => 
    [email] => testing@test.net.net
    [address1] => 22 Test St
    [address2] => 
    [city] => Testing
    [state] => New South Wales
    [postcode] => 2000
    [country] => AU
    [phonenumber] => +1.324234234234
    [password] => 
    [tax_id] => 
    [customfields] => Array
        (
            [3] => testy
        )

)

 

Response

Array
(
    [0] => Example Server
    [1] => Failed while creating an object. Server is unwilling to perform

Array
(
    [0] => Example Server
    [1] => Failed while creating an object. Server is unwilling to perform
    [2] => Array
        (
            [0] => Array
                (
                    [file] => /XXXX/public_html/members/includes/hooks/ldapsync.php
                    [line] => 53
                    [function] => create

Below are lines 18 - 62 from ldapsnc.php hook file

/** 
 * Hook - create user
 * 
 * @param array $vars
 */
function hook_ldapsync_createUser($vars)
{
    hook_ldapsync_loadClasses();

    $configs = MgLDAPSyncConfig::$config;
    $trialProducts = $configs['Example Server'];
    $isTrialAccount = false;
    $products = \WHMCS\Session::get("cart");

    if(is_array($products['products']))
    {
        foreach ($products['products'] as $key => $product) {
            if(in_array($product['pid'], $trialProducts['idsOfTrialProducts']))
            {
                $isTrialAccount = true;
                break;
            }
        }
    }

    foreach ($configs as $name => $params)
    {
        try
        {
            $manager = new MgLDAPSyncManager($params['server']['hostname'], $params['server']['port'], $params['server']['username'], $params['server']['password']);
            $object = new MgLDAPSyncObject('create', $params, $vars, $isTrialAccount);
            if(!isset($vars['notes']) || $vars['notes'] == '')
            {
                unset($object->attributes['description']);
            }
            $manager->create($object);
            
            logModuleCall('LDAP Sync', __FUNCTION__, $vars, array($name, $manager, $object, $products, $isTrialAccount, $result), '', array($params['server']['password']));
        }
        catch (\Exception $e)
        {
            logModuleCall('LDAP Sync', __FUNCTION__, $vars, array($name, $e->getMessage(), $e->getTrace()), '', array($params['server']['password']));
        }
    }
}

Hopefully enough info to go off by

Thank you

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated