Can you explain the significance of the $dn variable in the context of querying Active Directory with PHP?

The $dn variable in the context of querying Active Directory with PHP represents the Distinguished Name (DN) of an object in the directory. It is used to specify the location of the object within the directory structure when performing search operations. It is crucial to set the $dn variable correctly to target the desired object or container in Active Directory.

// Set the $dn variable to specify the location of the object within Active Directory
$dn = "CN=User,OU=Employees,DC=example,DC=com";

// Perform a search operation using the $dn variable
$search = ldap_search($ldap_connection, $dn, "(objectClass=*)");

// Process the search results
$results = ldap_get_entries($ldap_connection, $search);