Calling ldap_get_dn from LotusScript

Hi all,

I was wondering if anyone could help me with calling the Notes C API function ldap_get_dn from LotusScript. It returns a pointer to a null terminated string (LMBCS i assume) if successful, or a null pointer if not successful. Also I need the pointer value to free up the memory being used by the string using ldap_memfree. I have no idea how long the string is without searching for the trailing null, or what its maximum size could be. This is vaguely how I expect to proceed.

  1. Get the pointer, ptr = ldap_get_dn(ld, entry).

  2. If ptr = 0 stop and report error.

  3. Find out the length of the LMBCS string in characters (preferably not bytes) using some function which understands LMBCS strings and looks for the null.

  4. Allocate a LotusScript string that is big enough to hold the string using the value derived in step 3 above.

  5. Copy/Translate the LBMCS string to the LotusScript unicode string.

  6. Free up the original memory using ldap_memfree(ptr)

I know how to do steps 1, 2, 4, 6, but I need help with steps 3 and 5. Assuming my logic is correct of course.

thanks in advance,

Jim