大网数据广告活动
域与目录服务

The GetEx Method

· 52CE 我爱测

Some attributes can store one or more values.

Some attributes can store one or more values. For example, the otherTelephone attribute of a user object in Active Directory is a property that can have zero, one, or many values. Attributes that have multiple values are known as "multi-valued attributes". If the IADs::Get method is used to retrieve a multi-valued attribute, the results must be processed differently than if the attribute has a single value. The results provided by the IADs::GetEx method, however, are processed in the same manner, regardless if the attribute has a single or multiple values. In both cases, the IADs::GetEx method returns the values in an array.

The IADs::GetEx method retrieves properties from the property cache. If the specified property is not found in the cache, IADs::GetEx performs an implicit IADs::GetInfo call.

The IADs::GetEx method returns a variant array of variants regardless of the number of values returned from the server. This is true even if the attribute only contains one value.

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

The IADs::GetEx method can also be used for single-valued attributes. The results of a single-valued attribute are processed the same as the results for a multi-valued attribute.

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

If no value is set for the attribute, IADs::GetEx returns the error "Property not found in cache".

Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 05/31/2018
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。