Custom Directory Connector adding user/group/membership info


I am currently writing a custom directory connector using a PostgreSQL Database.

I need to add users/groups and membership information into the appropriate tables (cwd_user, cwd_group, cwd_membership) for my directory and I would like to know how to safely create new ids for the new records ? The id column doen’t use Autoincrement and is also not bound to a sequence which would help with this.

Any hints on how to do that safely would be greatly appreciated!