PhilWaldmann / openrecord

Make ORMs great again!
https://openrecord.js.org
MIT License
486 stars 38 forks source link

Add documentation or examples to use with ldap #100

Closed sanslash332 closed 4 years ago

sanslash332 commented 5 years ago

To connect with ldap, aparently you have to consider some things about the object class, the dn itself, etc, and all of these things aren't documented. So, can add how proper setup a connection and one model to use with ldap?

For example, is necesary create models for all levels of the tree? or only that object that you want

Example, if you root is o=org,ou=special,country=usa

the nex level is ou=people,o=org,ou=special,country=usa

And the model that you want to use, the base dn of all objects is:

ou=user,ou=people,o=org,ou=special,country=usa

What is the correct way to create a model for that level of the tree, how add the correct attributes... how do a find only over these level of the tree, etc.

¡thanks!

PhilWaldmann commented 4 years ago

Hi @sanslash332

sorry for my late response. LDAP is quite challenging because is depends on your ldap store and configuration. Take a look at the ldap test (e.g. for inserts

You create a model per objectType! And then you could search for that model in the whole tree, a subtree oder on with a specific dn (e.g. User.find('ou=user,ou=people,o=org,ou=special,country=usa'))

sanslash332 commented 4 years ago

Hello @PhilWaldmann,

O, don't worry. thanks for your answer!

And well, I know that, and for have a good connection between your LDAP's server and the ORM deppends of these things, but... Will be interesting have on the documentation a small example, using a tipical ldap configuration, only for give a small example how configure the models, etc.

So, when you talk about objectType, that type must be equals to a ObjectClass on ldap? using all the attributes that are seted on the objectClass? or you can use only a subset of these attributes.

And, inthe other hand. After configure the config of your oRM and use store.connect ¿how do you check the state of the connection?

How do you can check if the connection is stablished, have issues or something similar?

¡thanks for your answers, again! :3

PhilWaldmann commented 4 years ago

Hello @sanslash332

sorry for the really late reply. Totally overlooked your reply. The connection is done via ldapjs. ldapjs will try to BIND to your ldap store and will throw an appropriate error if it fails. This error will visible on the first query as far as I can remember.

I've updated the docs to get you started.

sanslash332 commented 4 years ago

O, don’t worry!

Thanks for your reply and the update in the docs!