We would strongly suggest you NOT use JNDI in real LDAP coding and instead use one of the dedicated JAVA LDAP SDKs that are available.
We were concentrating on clearly showing how to do these simple operations not trying to show off or ability to code.