简体   繁体   English

Unboundid不返回请求的LDAP属性。 为什么?

[英]Unboundid not returning requested LDAP attributes. Why?

I have written a program that reads a webservice, retrieving user data, and then is supposed to push that data to ActiveDirectory, thus updating the user's title, address, phone numbers, etc. 我编写了一个程序,该程序读取Web服务,检索用户数据,然后将其推入ActiveDirectory,从而更新用户的标题,地址,电话号码等。

The problem is that when I perform the search using the Unboundid Connection class the requested attributes are not returned. 问题是,当我使用Unboundid Connection类执行搜索时,未返回所请求的属性。 Below is the search code: 以下是搜索代码:

SearchResult result = connection.search( properties.getProperty("ldap.search.baseDN"), 
                        SearchScope.SUB, "(cn=" + userId + ")", 
                        "personalTitle", "department", "company", "manager", "telephoneNumber", 
                        "streetAddress", "I", "st", "postalCode", "c", "pager", "mobile", 
                        "fax", "cn");

The above code locates the desired user and the cn attribute is returned as expected, but the other attributes all fail to return. 上面的代码找到了所需的用户,并按预期返回了cn属性,但其他属性都无法返回。 If I connect to AD using JXplorer using the same connection credentials, I'm able to see all the desired attributes exist, but are simply not being returned. 如果我使用相同的连接凭据使用JXplorer连接到AD,则可以看到所有所需的属性存在,但根本不会返回。

在此处输入图片说明

I have tried substituting SearchRequest.ALL_OPERATIONAL_ATTRIBUTES, SearchRequest.ALL_USER_ATTRIBUTES and SearchRequest.REQUEST_ATTRS_DEFAULT rather than listing the fields explicitly, but with no success. 我尝试替换SearchRequest.ALL_OPERATIONAL_ATTRIBUTES,SearchRequest.ALL_USER_ATTRIBUTES和SearchRequest.REQUEST_ATTRS_DEFAULT,而不是明确列出字段,但没有成功。

I have also looked at the 'Schema' object returned from 'connection.getSchema()' and can see that personalTitle should exist: 我还查看了从“ connection.getSchema()”返回的“ Schema”对象,可以看到personalTitle应该存在:

connection.getSchema().getAttributeType("personalTitle")

The above code returns: 上面的代码返回:

1.2.840.113556.1.2.615 NAME 'personalTitle' SYNTAX '1.3.6.1.4.1.1466.115.121.1.15' SINGLE-VALUE 1.2.840.113556.1.2.615名称'personalTitle'语法'1.3.6.1.4.1.1466.115.121.1.15'单值

So maybe this is a user permission issue? 所以这可能是用户权限问题? Has anyone experienced this and know how to resolve it? 有没有人遇到过这种情况并且知道如何解决?

Thanks, Mike 谢谢,迈克

LDAP search result entries only include attributes that actually have values, so the behavior you are seeing from the UnboundID LDAP SDK is appropriate and correct. LDAP搜索结果条目仅包含实际具有值的属性,因此您从UnboundID LDAP SDK中看到的行为是正确的。 Even if you explicitly request a particular attribute, that attribute will only be included in the entry if it has one or more values. 即使您显式请求一个特定的属性,该属性也将仅包含在具有一个或多个值的条目中。

I think that you're confused by JXplorer because it's reading the schema to determine what attributes could possibly be included in the entry based on its object classes and is showing them to you so that you can set values for those attributes in the editor. 我认为您对JXplorer感到困惑,因为JXplorer正在读取架构以根据其对象类确定条目中可能包含哪些属性,并向您显示这些属性,以便您可以在编辑器中设置这些属性的值。 But that doesn't mean that the entry returned by the server actually includes any information about those attributes. 但这并不意味着服务器返回的条目实际上包括有关这些属性的任何信息。

To verify this, you can use the ldap-debugger tool provided with the LDAP SDK to see the actual LDAP communication that occurs. 为了验证这一点,您可以使用LDAP SDK随附的ldap-debugger工具来查看实际发生的LDAP通信。 Just run a command like: 只需运行以下命令:

 tools/ldap-debugger --hostname {directory-server-address} \
      --port {directory-server-port} --listenPort {listen-port}

This will create a very simple LDAP proxy server that decodes all requests and responses that pass through it. 这将创建一个非常简单的LDAP代理服务器,该服务器对通过它的所有请求和响应进行解码。 To use it, simply point JXplorer at the specified listen-port. 要使用它,只需将JXplorer指向指定的监听端口。 You will see that when JXplorer retrieves the entry, the entry returned by the server will only contain attributes that actually have values. 您将看到,当JXplorer检索条目时,服务器返回的条目将仅包含实际具有值的属性。

If you want to figure out what all the possible attributes are that you can include in a given entry, then use the LDAPConnection.getSchema method to retrieve the server schema, then Schema.getObjectClass for each of the object classes in the target entry, and finally use the ObjectClassDefinition.getRequiredAttributes and ObjectClassDefinition.getOptionalAttributes methods to see what attribute types must and may be used in entries with that object class. 如果要弄清楚可以包含在给定条目中的所有可能属性是什么,请使用LDAPConnection.getSchema方法检索服务器架构,然后使用Schema.getObjectClass获得目标条目中的每个对象类,并最后,使用ObjectClassDefinition.getRequiredAttributes和ObjectClassDefinition.getOptionalAttributes方法来查看哪些属性类型必须且可以在具有该对象类的条目中使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM