etyp / meteor-accounts-ldap

A Meteor package for logging in and creating users with LDAP credentials
MIT License
39 stars 23 forks source link

Trying to get a value for one of the fields returned in an ldap search to store in user profile, but getting size limit exceeded unhandled error #18

Open charford opened 8 years ago

charford commented 8 years ago

I'm trying to take a value from the ldap result and store it in the user's profile. The key is 'mail'. I have the following in server side code:

server/startup.coffee

LDAP_DEFAULTS.url = 'ldap://megavip.intern.company.net'
LDAP_DEFAULTS.base = 'ou=employees,ou=People,dc=intern,dc=company,dc=net'

LDAP_DEFAULTS.searchResultsProfileMap = [ 
  { resultKey: 'mail', profileProperty: 'email' }
]
W20160503-16:28:05.404(-7)? (STDERR) 
W20160503-16:28:05.404(-7)? (STDERR) events.js:72
W20160503-16:28:05.404(-7)? (STDERR)         throw er; // Unhandled 'error' event
W20160503-16:28:05.404(-7)? (STDERR)               ^
W20160503-16:28:05.406(-7)? (STDERR) SizeLimitExceededError: Size Limit Exceeded
W20160503-16:28:05.406(-7)? (STDERR)     at messageCallback (/Users/caseyharford/.meteor/packages/typ_ldapjs/.0.7.3.221nv3++os+web.browser+web.cordova/npm/node_modules/ldapjs/lib/client/client.js:867:40)
W20160503-16:28:05.406(-7)? (STDERR)     at Parser.onMessage (/Users/caseyharford/.meteor/packages/typ_ldapjs/.0.7.3.221nv3++os+web.browser+web.cordova/npm/node_modules/ldapjs/lib/client/client.js:199:12)
W20160503-16:28:05.406(-7)? (STDERR)     at Parser.emit (events.js:95:17)
W20160503-16:28:05.406(-7)? (STDERR)     at Parser.write (/Users/caseyharford/.meteor/packages/typ_ldapjs/.0.7.3.221nv3++os+web.browser+web.cordova/npm/node_modules/ldapjs/lib/messages/parser.js:105:8)
W20160503-16:28:05.406(-7)? (STDERR)     at end (/Users/caseyharford/.meteor/packages/typ_ldapjs/.0.7.3.221nv3++os+web.browser+web.cordova/npm/node_modules/ldapjs/lib/messages/parser.js:71:19)
W20160503-16:28:05.406(-7)? (STDERR)     at Parser.write (/Users/caseyharford/.meteor/packages/typ_ldapjs/.0.7.3.221nv3++os+web.browser+web.cordova/npm/node_modules/ldapjs/lib/messages/parser.js:107:10)
W20160503-16:28:05.406(-7)? (STDERR)     at Socket.onData (/Users/caseyharford/.meteor/packages/typ_ldapjs/.0.7.3.221nv3++os+web.browser+web.cordova/npm/node_modules/ldapjs/lib/client/client.js:155:24)
W20160503-16:28:05.407(-7)? (STDERR)     at Socket.emit (events.js:95:17)
W20160503-16:28:05.407(-7)? (STDERR)     at Socket.<anonymous> (_stream_readable.js:765:14)
W20160503-16:28:05.408(-7)? (STDERR)     at Socket.emit (events.js:92:17)

If I comment out the LDAP_DEFAULTS.searchResultsProfileMap code, then login works fine. However, if I have that code enabled, I get the above error in the console logs of the server, and login does not complete successfully.

My client side login code looks like this:

AutoForm.hooks
  loginForm:
    onSubmit: (insertDoc, updateDoc, currentDoc)->
      context = this
      dn = 'uid=' + insertDoc.username
      dn += ',ou=employees,ou=People,dc=intern,dc=company,dc=net'
      Meteor.loginWithLDAP insertDoc.username, insertDoc.password, {
        dn: dn
        search: '(objectclass=*)'
      }, (err) ->
        if err 
          context.done(new Error(err))
        else
          context.done()
        return
      false

Any ideas what the size limit error is about? For what its worth, from command line I am able to execute:

ldapsearch -x -h megavip.intern.company.net -b "uid=myusername,ou=employees,ou=People,dc=intern,dc=company,dc=net"

And I get a list of keys/values, along with the mail key/value i'm trying to get access to. So I know the info exists in the ldap directory, but for some reason I can't access it because of the above error.

tomsen-san commented 8 years ago

Seeing the same problem. Taking out the profileMap allows login. I try to fetch the username from ldap with this map

LDAP_DEFAULTS.searchResultsProfileMap=[{
        resultKey: 'cn',
        profileProperty: 'name'
    }];
tomsen-san commented 8 years ago

After reading other comments here, upgraded manually to version 1.1.0. Same problem. Can anyone give some directions how to debug this?

charford commented 8 years ago

I never found a solution to this issue. I ended up using the command line to query ldap directly for the info I needed, rather than using this library (not ideal, but it works).

madhan5000 commented 8 years ago

I am having the same issue :(

ravusandeep commented 7 years ago

I am facing same issue. Please give me some solution.

mattheobjornson commented 7 years ago

Seems that when you set LDAP_DEFAULTS.base, all records that match this base are fetched from LDAP (such query usually exceeds size limit that ldapjs allows). When you set base to null, only result that matches the DN query is fetched from LDAP.