It might be work checking that the sess idx isn't already in use by
calling getSession(idx) and returning a error is it doesn't return NULL.
Alternatively, rather than having the user specifying the sess idx to
kdbldap_init(), you could generate a unique value, e.g. use a session counter
that gets incremented every time a session is added (but is not decremented
on session remove)
init currently returns an ldap error code - so an error code due to session already used may have to use an ldap error code to exist in current mechanism
It might be work checking that the sess idx isn't already in use by calling getSession(idx) and returning a error is it doesn't return NULL. Alternatively, rather than having the user specifying the sess idx to kdbldap_init(), you could generate a unique value, e.g. use a session counter that gets incremented every time a session is added (but is not decremented on session remove)