Condividi tramite


Metodo GetEx

Alcuni attributi possono archiviare uno o più valori. Ad esempio, l'altro attributoTelephone di un oggetto utente in Active Directory è una proprietà che può avere zero, uno o molti valori. Gli attributi con più valori sono noti come "attributi multivalore". Se il metodo IADs::Get viene usato per recuperare un attributo multivalore, i risultati devono essere elaborati in modo diverso rispetto a se l'attributo ha un singolo valore. I risultati forniti dal metodo IADs::GetEx , tuttavia, vengono elaborati nello stesso modo, indipendentemente dal fatto che l'attributo abbia un singolo o più valori. In entrambi i casi, il metodo IADs::GetEx restituisce i valori in una matrice.

Il metodo IADs::GetEx recupera le proprietà dalla cache delle proprietà. Se la proprietà specificata non viene trovata nella cache, IADs::GetEx esegue una chiamata IADs::GetInfo implicita.

Il metodo IADs::GetEx restituisce una matrice di varianti indipendentemente dal numero di valori restituiti dal server. Questo vale anche se l'attributo contiene un solo valore.

Dim usr As IADs
On Error GoTo Cleanup

Set usr = GetObject("LDAP://CN=Jeff Smith,CN=Users,DC=fabrikam,DC=com")
homePhones = usr.GetEx("otherHomePhone")
For each phone in homePhones
    Debug.Print phone
Next

Cleanup:
    If (Err.Number<>0) Then
        MsgBox("An error has occurred. " & Err.Number)
    End If
    Set usr = Nothing

Il metodo IADs::GetEx può essere usato anche per gli attributi a valore singolo. I risultati di un attributo a valore singolo vengono elaborati come i risultati di un attributo multivalore.

Dim usr as IADs
On Error GoTo Cleanup

Set usr = GetObject("LDAP://CN=Jeff Smith,CN=Users,DC=fabrikam,DC=com")
sds = usr.GetEx("ntSecurityDescriptor")
For each sd in sds
    Set acl = sd.DiscretionaryACL
Next

Cleanup:
    If (Err.Number<>0) Then
        MsgBox("An error has occurred. " & Err.Number)
    End If
    Set usr = Nothing

Se per l'attributo non è impostato alcun valore, IADs::GetEx restituisce l'errore "Proprietà non trovata nella cache".