Sorry, forgot about that. Here is a quote you need:
userService.addUserAttribute(user_name, "LDAPAttributeName", user_uid)
And to find user by this "LDAPAttributeName" we use:
find_user_by_LDAPAttributeName = userService.getUserByAttribute("LDAPAttributeName", user_uid)
It's standard approach to store all external GUIDs in "oxExternalUid" with prefix. Also we instruct LDAP to index this attribute to do quick search.
Please refer to the links I provided above to see full list of functions you can employ and how to use them.