Skip to content
This repository has been archived by the owner on Jul 24, 2023. It is now read-only.

Search query does not returning User Model Instance instead it is returning Entry Model instance after upgrading the package to v10.3.3 #793

Open
Meghabm07 opened this issue Nov 22, 2021 · 1 comment

Comments

@Meghabm07
Copy link

  • Adldap2 Version: 10.3
  • LDAP Type: OpenLDAP
  • PHP Version: 7.4

Description:

After upgrading to Adldap2 Version: 10.3 from 7.0 the search query does not return User Model Instance instead it is returning Entry Model instance. Because of this, I'm not able to retrieve the getObjectGuid() In v7.0 the same code was working fine.
I have also checked the documentation but did not find any solution.

Steps To Reproduce:

private function updateAllUsers() {
	
		$this->connect();
		
		$this->out("\tRetrieving all users...");

		$search = $this->ldap->search();
		$paginator = $search->in('dc=testldap,dc=com')->rawFilter("(&(objectclass=inetOrgPerson)(objectclass=inetorgperson))")->select(['*','entryuuid'])->paginate(900, 1);
		$results = $paginator->getResults();

		if(count($results) == 0) {
			$this->out("\tNo users found! Perhaps your query is wrong?");
			return;
		}

		$this->out("\tGot ".count($results). " users");
		foreach($results as $result) {
			$sid = $result->getObjectGuid();
			if(empty($sid)) {
				$this->out("\t\tERROR User is missing ".$this->config['externalidattr']." attribute! Cant continue!!");
				continue;
			}
		}
}

Output

Array
(
    [0] => Adldap\Models\Entry Object
        (
            [exists] => 1
            [query:protected] => Adldap\Query\Builder Object
                (
                    [columns] => Array
                        (
                            [0] => *
                        )

                    [filters] => Array
                        (
                            [and] => Array
                                (
                                )

                            [or] => Array
                                (
                                )

                            [raw] => Array
                                (
                                )

                        )

                    [limit] => 0
                    [paginated] =>
                    [sortByField:protected] =>
                    [sortByDirection:protected] =>
                    [sortByFlags:protected] =>
                    [dn:protected] => dc=testldap,dc=com
                    [type:protected] => search
                    [raw:protected] =>
                    [nested:protected] =>
                    [caching:protected] =>
                    [cacheUntil:protected] =>
                    [flushCache:protected] =>
                    [connection:protected] => Adldap\Connections\Ldap Object
                        (
                            [name:protected] =>
                            [host:protected] => ldap://192.168.3.116:389
                            [connection:protected] => Resource id #538
                            [bound:protected] => 1
                            [useSSL:protected] =>
                            [useTLS:protected] =>
                        )

                    [grammar:protected] => Adldap\Query\Grammar Object
                        (
                        )

                    [schema:protected] => Adldap\Schemas\ActiveDirectory Object
                        (
                        )

                    [cache:protected] =>
                )

            [schema:protected] => Adldap\Schemas\ActiveDirectory Object
                (
                )

            [modifications:protected] => Array
                (
                )

            [dateFormat] => Y-m-d H:i:s
            [timestampFormat:protected] => YmdHis.0Z
            [attributes:protected] => Array
                (
                    [cn] => Array
                        (
                            [0] => test1 test1
                        )

                    [0] => cn
                    [givenname] => Array
                        (
                            [0] => test1
                        )

                    [1] => givenname
                    [gidnumber] => Array
                        (
                            [0] => 500
                        )

                    [2] => gidnumber
                    [homedirectory] => Array
                        (
                            [0] => /home/users/ttest1
                        )

                    [3] => homedirectory
                    [sn] => Array
                        (
                            [0] => test1
                        )

                    [4] => sn
                    [objectclass] => Array
                        (
                            [0] => inetOrgPerson
                            [1] => posixAccount
                            [2] => top
                        )

                    [5] => objectclass
                    [uidnumber] => Array
                        (
                            [0] => 1000
                        )

                    [6] => uidnumber
                    [uid] => Array
                        (
                            [0] => ttest1
                        )

                    [7] => uid
                    [entryuuid] => Array
                        (
                            [0] => 082d2df8-6cd5-103a-8855-67335f1940d7
                        )

                    [8] => entryuuid
                    [title] => Array
                        (
                            [0] => Mrss
                        )

                    [9] => title
                    [distinguishedname] => Array
                        (
                            [0] => cn=test1 test1,dc=testldap,dc=com
                        )

                )

            [original:protected] => Array
                (
                    [cn] => Array
                        (
                            [0] => test1 test1
                        )

                    [0] => cn
                    [givenname] => Array
                        (
                            [0] => test1
                        )

                    [1] => givenname
                    [gidnumber] => Array
                        (
                            [0] => 500
                        )

                    [2] => gidnumber
                    [homedirectory] => Array
                        (
                            [0] => /home/users/ttest1
                        )

                    [3] => homedirectory
                    [sn] => Array
                        (
                            [0] => test1
                        )

                    [4] => sn
                    [objectclass] => Array
                        (
                            [0] => inetOrgPerson
                            [1] => posixAccount
                            [2] => top
                        )

                    [5] => objectclass
                    [uidnumber] => Array
                        (
                            [0] => 1000
                        )

                    [6] => uidnumber
                    [uid] => Array
                        (
                            [0] => ttest1
                        )

                    [7] => uid
                    [entryuuid] => Array
                        (
                            [0] => 082d2df8-6cd5-103a-8855-67335f1940d7
                        )

                    [8] => entryuuid
                    [title] => Array
                        (
                            [0] => Mrss
                        )

                    [9] => title
                    [distinguishedname] => Array
                        (
                            [0] => cn=test1 test1,dc=testldap,dc=com
                        )

                )

        )
)

@stevebauman
Copy link
Member

Hi @Meghabm07,

Moving from version 7-10 is a huge jump in major versions. Have you configured your connection to use the OpenLDAP schema?

Also, I would heavily recommend moving to LdapRecord. I can support you with that project and it has much better documentation and feature set. I hope I see you over there!

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

No branches or pull requests

2 participants