question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: urlStr + ' is an invalid LDAP url (scope)'

See original GitHub issue

Hi, I am using this very simple code to connect to LDAP but no matter what i keep on getting the following error:

var ldap = require('ldapjs'); 
var client = ldap.createClient({url:'ldap://openam.sandbox.local:10389'}); 
client.bind('cn=DM', 'test', function(err) {
  if (err){
    console.log("not able to connect")
  }     else      { 
    console.log("connected successfully")
  }
});

I am using mac.

/Users/ashishjindal/Projects/sw-app-api/api-testing/node_modules/ldapjs/lib/url.js:15
      throw new TypeError(urlStr + ' is an invalid LDAP url (scope)')
      ^

TypeError: ldap://openam.sandbox.local:10389 is an invalid LDAP url (scope)
    at Object.parse (/Users/ashishjindal/Projects/sw-app-api/api-testing/node_modules/ldapjs/lib/url.js:15:13)
    at new Client (/Users/ashishjindal/Projects/sw-app-api/api-testing/node_modules/ldapjs/lib/client/client.js:114:33)
    at Object.createClient (/Users/ashishjindal/Projects/sw-app-api/api-testing/node_modules/ldapjs/lib/client/index.js:17:12)
    at Object.<anonymous> (/Users/ashishjindal/Projects/sw-app-api/api-testing/tests/builders/ldap.js:3:19)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)

[Done] exited with code=1 in 0.148 seconds

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
JohnGratcommented, Mar 26, 2021

i got it working my changing url.URL to url.Parse parsedURL = new url.parse(urlStr) //parsedURL = new url.URL(urlStr) } catch (error) {

0reactions
pchoudhary17commented, Nov 17, 2022

URL.parse has been deprecated since Node.js 11 – https://nodejs.org/dist/latest-v14.x/docs/api/url.html#url_url_parse_urlstring_parsequerystring_slashesdenotehost

URL.URL was added in Node.js 10 – https://nodejs.org/dist/latest-v14.x/docs/api/url.html#url_class_url

Please provide a minimal reproduction if you are encountering this error with Node.js >= 10 and ldapjs >= 2.

I’m using ldapjs 2.3.3 and node 18.12.0 but still encoutering the same error in ldap.createClient. I tried to console log url.parse and that works but url.URL seems to not. while parsing using URL hostname and port are null and everyting is getting added to pathname only.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ldapjs can't connect with a server - Stack Overflow
js we need to do the following changes, after the changes it working fine. Error: parsedURL = new url.URL(urlStr). Solution: parsedURL = new ......
Read more >
Error: urlStr + ' is an invalid LDAP url (scope)' - Bountysource
Hi, I am using this very simple code to connect to LDAP but no matter what i keep on getting the following error:...
Read more >
LDAP URLs
An LDAP URL is a string that can be used to encapsulate the address and port of a directory server, the DN of...
Read more >
LDAP client and server APIs - GitHub Pages
'sub') throw new TypeError(urlStr + ' is an invalid LDAP url (scope)'); u.scope = tmp[1]; } if (tmp[2]) { u.filter = querystring.unescape(tmp[2]); }...
Read more >
APM Cookbook: Modify LDAP Attribute Values using iRulesLX
throw new TypeError(urlStr + ' is an invalid LDAP url (scope)'). } Note that although the error message says "(scope)", I do not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found