问题是,当我尝试用Java在Active Directory (AD)中创建用户时,我得到了这个异常,但是当我想从已经存在的用户中获取值时,就没有问题了。我需要一种解决方案,让它不仅在我的计算机上本地工作,而且在全球范围内工作(我不想强迫其他人进行相同的配置)。
我尝试导入/导出ssl证书,但有2个问题。第一个是它没有工作,第二个是即使它以这种方式工作,这将只是一个局部解决方案。
public void createUser(String username, String surname, String givenName) throws NamingException {
//the exception is right here when I'm trying to initialize
DirContext context = new InitialDirContext(ldapEnv);
String distinguishedName = "cn=" + username + BASE;
Attributes newAttributes = new BasicAttributes(true);
Attribute objClasses = new BasicAttribute("objectclass");
objClasses.add("top");
objClasses.add("person");
objClasses.add("organizationalperson");
objClasses.add("user");
newAttributes.put(objClasses);
newAttributes.put(new BasicAttribute("sAMAccountName", username));
newAttributes.put(new BasicAttribute("cn", username));
newAttributes.put(new BasicAttribute("sn", surname));
newAttributes.put(new BasicAttribute("givenName", givenName));
newAttributes.put(new BasicAttribute("displayName", givenName + " " + surname));
System.out.println("Creating: " + username);
context.createSubcontext(distinguishedName, newAttributes);
}发布于 2019-10-22 21:20:59
没有与IP地址匹配的主题备用名称
这个问题似乎适用于任何SSL连接,而不仅仅是LDAP。
SSL证书具有主域名和“使用者替代名称”,它们是证书可用于的其他域名的列表。当您启动SSL连接时,您的计算机将读取证书,查看允许使用证书的所有域名,并检查其中是否有与您用于启动连接的域名相匹配的域名。这是为了确保您连接到正确的服务器,因为这是安全通信工作的一部分(不仅仅是加密)。
问题是:如果您使用IP地址,如下所示:
ldapEnv.put(Context.PROVIDER_URL, "ldaps://192.168.1.1:636");那么SSL握手肯定会失败,因为SSL证书不会颁发给IP地址。您必须使用SSL证书中列出的域名之一:
ldapEnv.put(Context.PROVIDER_URL, "ldaps://example.com:636");https://stackoverflow.com/questions/58504812
复制相似问题