ldapjs / node-ldapjs

LDAP Client and Server API for node.js
http://ldapjs.org
MIT License
1.61k stars 442 forks source link

Tyring to implement cn=Subschema #937

Closed Whidix closed 1 year ago

Whidix commented 1 year ago

Hello, anyone know if it's possible to send Subschema when running as a server ? Here is my code :

 // Subschema
server.search('cn=Subschema', async (req, res, next) => {
  console.log('DN: ' + req.dn.toString());
  console.log('Filter: ' + req.filter.toString());
  console.log('Attributes: ' + req.attributes.toString());
  console.log('Scope: ' + req.scope);

  try {
    if (req.attributes.includes('objectClasses')) {
      res.send({
        dn: 'cn=Subschema',
        attributes: {
          objectClasses: subschema,
        },
      });
    } else {
      res.send({
        dn: 'cn=Subschema',
        attributes: {
          objectClass: ['top', 'subentry', 'subschema', 'extensibleObject'],
        },
      });
    }
    res.end();
    return next();
  } catch (error) {
    console.error('Error handling search request:', error);
    res.end(new ldap.OtherError(error.message));
    return next(error);
  }
});

Here subschema is a list of schema like "( 2.5.6.0 NAME 'top' DESC 'top of the superclass chain' ABSTRACT MUST objectClass )"

The issue is that I'm unable to query them, here is the output:

> ldapsearch -H ldap://localhost:3389 -x -s base -b "cn=Subschema" objectClasse
# extended LDIF
#
# LDAPv3
# base <cn=Subschema> with scope baseObject
# filter: (objectclass=*)
# requesting: objectClasse 
#

# Subschema
dn: cn=Subschema

# search result
search: 2
result: 0 Success

# numResponses: 2
# numEntries: 1

Thank you.

jsumners commented 1 year ago

To the best of my knowledge, the server library imposes no limitations on what you can implement. I would recommend reading the spec. You can start with https://ldap.com/retrieving-schema-over-ldap/, which indicates that "objectClasses", as you have in your example, is incorrect.

jsumners commented 1 year ago

Closing due to lack of response.