nxlog 生成的日志中有一个具有以下格式的打印机设备的 GUID:
119d0d80-699d-4e81-8e4e-5477e22ac1b3
我想通过 LDAP 解析其 GUID 来获取设备名称。然而,我遇到的最近的字段是 objectGUID
在 ldapsearch响应,这显然是 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/