import javax.naming.directory.*; // Create a directory context DirContext ctx = new InitialDirContext(); // Retrieve the distinguished name of an entry Attributes attrs = ctx.getAttributes("cn=John Doe,ou=People,dc=example,dc=com"); String dn = attrs.get("distinguishedName").get().toString();In this example, we create a directory context using the InitialDirContext class. Then, we use the getAttributes method to retrieve the attribute values for a directory entry with the common name "John Doe", located in the "People" organizational unit of the "example.com" domain. Finally, we retrieve the distinguished name of the entry using the get method on the "distinguishedName" attribute. The Entry class is part of the javax.naming.directory package, which is part of the Java Platform, Standard Edition (Java SE) library.