in reply to data comparison

I regret I can't help you (I haven't worked with LDAP). For my brother monks who can, I suggest you bracket your code with <code> and </code>.

This will make your program much more readable.