We are using OpenLDAP (openldap-server-2.4.11-bdb) and Berkley DB
(db-4.6.21)

in a project.

LDAP is used to store subscribernumbers and the address of the ippbx
where the
subscriber is registered. Typically every subscriber have a separate DN
in the

LDAP-database. We have a serverfunction that do ldap-searches for

subscribernumbers to retrieve the ippbx-address. This part is going to
remain

working as is.

Now we want to be able to have a "wildcard"-entry in LDAP, that points
to an
address also. This entry shall respond to any ldap-search matching the
wildcard.

Let me give an example:

We have, let's say four ippbx's with prefixes 111, 222, 333 & 444. A
subscriber-
number consist of the prefix and five more digits. Each subscriber can
be registered

in any ippbx and still be reachable. The prefix indicates the subscribers
"home-location".
Now we want to use a gateway to another telephone-system. We don't want to
have all of the subscribers from that system registered in LDAP, so we want

a "wildcard"-entry saying that if you dial 99912345 LDAP should have an
entry
999xxxx pointing to the gateway for the subscribers in the other
telephonesystem.
The response to the ldap-search should contain the the gateway address
to the

telephone-system regardless of the number entered. So if I dial 99912345 I
should get the same response as if I dial 99967890.

The response shall have the same format as in the ippbx-solution. We
want the ldap
DIT to look the same for the wildcard and the others - the DN shall look
the same.

We don't want to change the serverfunction we are using today.
So - finally my question:

Would it be possible to solve this with OpenLDAP and if so - how can it
be done?

The best way to handle this would be to move the logic towards the
application. If you want LDAP (and OpenLDAP) do handle it, you need to
move your application's logic into OpenLDAP. This requires to write
some code. You need to be able to intercept operations that requests
external numbers, and return a referral to the system that is able to
handle that request. Optionally, you can chain the request, so that the
client doesn't even need to handle the referral itself.

It might be pretty straightforward by defining an overlay that does the
The Right Thing (TM); of course, the devil is in the details, as usual.

<commercial>You might need expert support to have this done quick and
right.</commercial>