Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync Issue with name #42

Open
kirancheema opened this issue Jun 30, 2015 · 5 comments
Open

Sync Issue with name #42

kirancheema opened this issue Jun 30, 2015 · 5 comments

Comments

@kirancheema
Copy link

Hi I think there may be an issue with the sync of the name field.

I have an LDAP cron set up.
I have the authentication adapter active and the profile adapter active.

The profile adapter is set to sync Name = pull only & email = pull only

I thought that these should Sync when the user logs in and when the LDAP_CRON.php is run?

However the Name field doesn't seem to be updating when the CLI script is run.

I have manually run the script from the CLI and the only way to update the name is to remove the user and the run the cli script again..

Is that right? have i missed something? does the name not sync on cli cron?

the other thing that i noticed is that when i manually run the cli i get the following error notice.

Notice: Trying to get property of non-object in C:\UniServer\www\sandbox\scwcsu
libraries\shmanic\user\adapters\ldap.php on line 566

which is the getFullname function ...

@kirancheema
Copy link
Author

I have tried 2.0.2 and 2.0.3 still happening?

@kirancheema
Copy link
Author

Update on this issue..

Ldap-profile plugin - enabled.

Sync on login yes

Allow push - YES (also tried with No)

Sync name - pull only
Sync e-mail - pull only

I'm also using the Profile fields

I have "discovered" that Ldap_cron will update the profile fields but not the name and e-mail fields

name & email Will only Sync on login ... is that how it is supposed to be?

@kirancheema
Copy link
Author

so having investigated further there is definitely an issue with the getFullname(); function in users\adapters\Ldap.php

profile.php calls $adapter->getFullname(); in Function updateMandatory();

which is returning empty and not updating the jUser object

it is failing on $key = $this->client->keyName; line 566;

I'm not sure where that is going but if someone can point me in the right direction that would be grand,

does $this->client = new SHLdap() ? or SHLdap::getInstance();

not sure if this is an issue with getEmail as well?

@kirancheema
Copy link
Author

actually this change seemed to make it work, don't know if it is the right thing to do but it updates the name on cron sync ....

public function getFullname($key = false, $default = null)
    {
        if ($key)
        {
            // Only return the key id
            $this->getId(false);

            return $this->client->keyName;
        }
        $this->client = SHLdap::getInstance(
                    $this->domain, array(
                        'authenticate' => SHLdap::AUTH_PROXY)
                );
        // Find the Ldap attribute name key
        $key = $this->client->keyName;

        if ($value = $this->getAttributes($key))
        {
            if (isset($value[$key][0]))
            {
                // Fullname found so lets return it
                return $value[$key][0];
            }
        }

        return $default;
    }

@jbrailas
Copy link

If we place print_r($this->client) in line 3 before "if ($key)" then we can see that attribute keyName doesn't exist.
Now if we place print_r("fullname is " . $this->client->ldap_fullname); then it will output the key name which is "name" according to switch of the public function __get($name) in ldap\ldap.php file.
Using the cron sync $this->client is null, so we must check for null value.
The full code of the function is:

public function getFullname($key = false, $default = null) {
	if (is_null($this->client))
		$this->client = SHLdap::getInstance(
                $this->domain, array(
                    'authenticate' => SHLdap::AUTH_PROXY)
        );
	
	if ($key) {
		// Only return the key id
		$this->getId(false);
		return $this->client->keyName;
	}

	// Find the Ldap attribute name key
	if (!is_null($this->client->keyName))
		$key = $this->client->keyName;
	else
		$key = $this->client->ldap_fullname;

	if ($value = $this->getAttributes($key))	{
		if (isset($value[$key][0])) 	{
			// Fullname found so lets return it
			return $value[$key][0];
		}
	}
	return $default;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants