if (controlInfo.connectUsingStartTLS())
{
usedUrl = controlInfo.getStartTLSURL();
if (usedUrl == null)
{
throw new ConfigReadException(
ERR_COULD_NOT_FIND_VALID_LDAPURL.get());
}
ctx = Utils.createStartTLSContext(usedUrl,
bindDN, pwd, controlInfo.getConnectTimeout(), null,
controlInfo.getTrustManager(), null);
}
else if (controlInfo.connectUsingLDAPS())
{
usedUrl = controlInfo.getLDAPSURL();
if (usedUrl == null)
{
throw new ConfigReadException(
ERR_COULD_NOT_FIND_VALID_LDAPURL.get());
}
ctx = Utils.createLdapsContext(usedUrl,
bindDN, pwd, controlInfo.getConnectTimeout(), null,
controlInfo.getTrustManager());
}
else
{
usedUrl = controlInfo.getLDAPURL();
if (usedUrl == null)
{
throw new ConfigReadException(
ERR_COULD_NOT_FIND_VALID_LDAPURL.get());
}
ctx = Utils.createLdapContext(usedUrl,
bindDN, pwd, controlInfo.getConnectTimeout(), null);
}