adldap2:无法检索自定义用户属性

adldap2: unable to retrieve custom user attribute

我写了一个小 php 脚本来检索某个组中的所有用户并获得两个值,usernameemployeeid。不幸的是,第二个字段总是空的。但是在 Go 中完成了类似的查询 returns 的值。我已经阅读 Adldap docs 好几遍,但无法弄清楚哪里出了问题。

这是我正在使用的代码:

        $ad = new \Adldap\Adldap();
        $ad->addProvider($config);
        $userlist = [];
        try {
            $provider = $ad->connect();
            $group = $provider->search()->groups()->find($groupname);
            foreach ($group->getMembers() as $user) {
                $userlist[] = [
                    'AccountName' => $user->getAccountName(),
                    'EmployeeId' => $user->getEmployeeId(),
                ];
            }
        } catch (\Adldap\Auth\BindException $e) {
            echo $e->getMessage();
        }

这是 Go 中的相关工作部分。这里我只检索了一个用户元素:

func BindAndSearch(l *ldap.Conn, username string) (*ldap.SearchResult, error) {
    l.Bind(BindUsername, BindPassword)

    searchReq := ldap.NewSearchRequest(
        BaseDN,
        ldap.ScopeWholeSubtree,
        ldap.NeverDerefAliases,
        0,
        0,
        false,
        fmt.Sprintf(Filter, ldap.EscapeFilter(username)),
        []string{"employeeID"},
        nil,
    )
    result, err := l.Search(searchReq)
...

找到 答案,这正是我的问题:

I was Connecting to the AD via port 3268. It seems some attributes can be fetched only by connecting to the AD via port 389.