Jump to content

"ldap_get_entries" não retorna 1 dos atributos


pedro456789

Recommended Posts

Olá pessoal, 

Estou tentando obter alguns valores do meu Active Directory através do "ldap_get_entries", a conexão está funcional e consigo obter vários atributos, porém o atributo "ms-Mcs-AdmPwd" sempre retorna em branco mesmo estando populado no Active Directory.

Já tentei inclusive colocar as credenciais de administrador do domínio para validar as permissões e mesmo assim só tenho retorno do atributo "name".

Outros atributos como cn retornam OK, porém atributos operatingSystem e sAMAccountName também não retornam mesmo que sejam inclusos no filtro $justthese.

 

<?php
	
		$ldap_columns = NULL;
		$ldap_connection = NULL;
		$ldap_password = 'password';
		$ldap_username = 'user@XYZ.com.br';
		$ldap_server = 'ldaps://XYZ.com.br';

		$ldap_connection = ldap_connect($ldap_server);
		if (FALSE === $ldap_connection){
			die("<p>Failed to connect to the LDAP server: ". $ldap_server ."</p>");
		}

		ldap_set_option($ldap_connection, LDAP_OPT_PROTOCOL_VERSION, 3) or die('Unable to set LDAP protocol version');
		ldap_set_option($ldap_connection, LDAP_OPT_REFERRALS, 0);

		if (TRUE === ldap_bind($ldap_connection, $ldap_username, $ldap_password)){
			$justthese = array('name','ms-Mcs-AdmPwd');
			$result = ldap_search($ldap_connection, "DC=XYZ,DC=com,dc=br", "(&(objectClass=Computer)(name=ABCD))", $justthese);
			
			$info = ldap_get_entries($ldap_connection, $result) or die ("Erro!");
			
			echo $info[0]["ms-Mcs-AdmPwd"][0];
			
			if ($info[0]["name"][0] != ''){

				echo $info[0]["name"][0];
				
			}
		}
?>

Se alguém puder ajudar agradeço muito.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.