java - 在 Java 的 ActiveDirecotry 中通过 LDAP 解析对象的 GUID 来获取对象的名称

标签 java active-directory ldap guid

nxlog 生成的日志中有一个具有以下格式的打印机设备的 GUID:

119d0d80-699d-4e81-8e4e-5477e22ac1b3

我想通过 LDAP 解析其 GUID 来获取设备名称。然而,我遇到的最近的字段是 objectGUIDldapsearch响应,这显然是 Base64编码值:

objectGUID:: fuAW6fefLke30d46TDTUWA==

<小时/>

上面这两个 GUID 有什么关系吗? (也就是说,格式转换后,我是否应该在 objectGUID 中的 AD 字段中搜索第一个 GUID?

如何使用 LDAP 获取对象名称java中的查询?

不可能通过 getAttribute() 实现这一目标方法和下面的代码:

        //Create the initial directory context
        LdapContext ctx = new InitialLdapContext(env,null);

        //Bind directly using the string form of the GUID
        String strGUID = "<GUID="+guid+">";

        //Specify the attributes to return
        String returnedAtts[]={"distinguishedName"};

        Attributes attr = ctx.getAttributes(strGUID,returnedAtts);

        //print out the retrieved attributes
        if(attr!=null)
            distinguishedName = attr.get("distinguishedName").get().toString();
        System.out.println("distinguishedName: " + distinguishedName);

        ctx.close();

我得到了NameNotFoundException :

javax.naming.NameNotFoundException: [LDAP: error code 32 - 0000208D: NameErr: DSID-0310021B, problem 2001 (NO_OBJECT), data 0, best match of:
    ''

姓名( <GUID="+guid+"> )的格式是否正确? (我在 ldapsearch 的响应输出中没有看到任何使用此格式的迹象)

最佳答案

ObjectGuid Microsoft Active Directory 中使用的 GUID 与必须的 GUID 相比有点奇怪。

您必须应对几个方面,包括 Endianness

我确实找到了一些Java Code的引用.

关于java - 在 Java 的 ActiveDirecotry 中通过 LDAP 解析对象的 GUID 来获取对象的名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58789909/

相关文章:

java - 如何让 Runtime.exec() "take over"调用控制台的应用程序直到完成?

asp.net-core - 如何将 asp.net core windows 身份验证与 Cookie 身份验证一起使用?

c# - 通过 SSL 查询 AD 域

java - 如何通过 Java 代码在没有完整 CN/DN 的情况下连接 Active Directory

java - 抛出什么异常?

java - 建议 : Java GUI Using JFrame

PHP - ldap_search() 过滤器。如何搜索用户

c# - 如何在 C# 中转义字符串,以便在 LDAP 查询中使用

java - hibernate.jdbc.fetch_size 和 hibernate.jdbc.batch_size 有什么区别?

java - 从 Active Directory 检索密码过期警告