赞
踩
安全组属性objectSid、objectGUID直接转为string会出现乱码,需要将其先转为byte再转为string
具体实现
env.put("java.naming.ldap.attributes.binary", "objectSid objectGUID");
byte[] sidBytes = (byte[]) attributes.get("objectSid").get();
String objectSid = bytesToHexString(sidBytes));
public static String bytesToHexString(byte[] bytes) {
StringBuilder hexString = new StringBuilder();
for (byte b : bytes) {
String hex = Integer.toHexString(0xFF & b);
if (hex.length() == 1) {
hexString.append('0');
}
hexString.append(hex);
}
return hexString.toString();
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。