diff --git a/lib/url.js b/lib/url.js index 724cb75..6e391f1 100644 --- a/lib/url.js +++ b/lib/url.js @@ -15,16 +15,16 @@ module.exports = { if (!u.protocol || !(u.protocol === 'ldap:' || u.protocol === 'ldaps:')) throw new TypeError(urlStr + ' is an invalid LDAP url (protocol)'); - if (!u.port) { - u.port = 389; - } else { - u.port = parseInt(u.port, 10); - } + u.secure = (u.protocol === 'ldaps:'); if (!u.hostname) u.hostname = 'localhost'; - u.secure = (u.protocol === 'ldaps:'); + if (!u.port) { + u.port = (u.secure ? 636 : 389); + } else { + u.port = parseInt(u.port, 10); + } if (u.pathname) { u.pathname = querystring.unescape(u.pathname.substr(1));