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

Binding to Active Directory Objects

· 52CE 我爱测

Before you continue with this scenario, you must understand how ADSI objects are named in Active Directory, and how to bind them. Binding an ADSI object connects the object with the directory service, and allows you to access the methods of the object.

Before you continue with this scenario, you must understand how ADSI objects are named in Active Directory, and how to bind them. Binding an ADSI object connects the object with the directory service, and allows you to access the methods of the object.

ADsPath

An ADSI object is uniquely identified by its binding string, which is also referred to as an ADsPath. An ADsPath is a combination of a programmatic identifier (progID) of the ADSI provider, and the distinguished name (DN) of the object.

Here's the format of an ADsPath:

"progID://DN"

  • pogID — the programmatic identifier of the ADSI provider, such as LDAP or WinNT.

  • :// — separates the progID from the DN.

  • DN — the distinguished name of the ADSI object, which is the full path of the object, where the path consists of relative distinguished names (RDNs).

An RDN is the name of the object without the path, and is unique from its sibling objects. An RDN consists of an attribute ID and value, such as "DC=Fabrikam", where DC is the attribute, and Fabrikam is the value. DC is an RDN attribute ID that stands for domain component.

Here’s an example of an ADsPath:

"LDAP://DC=Fabrikam,DC=Com"

Binding the object

Here's how you can bind the domain object in this scenario:

Set dom = GetObject("LDAP://DC=Fabrikam,DC=Com")

When you run this code example, ADSI uses the DN to determine the ADSI objects to bind. After ADSI binds these objects, you can access their methods. The previous code example binds a domain object to IADs and IADsContainer. You can now use methods on those interfaces such as Get, Put, Create, Delete, and MoveHere.

After you bind a domain object, you can print some of its attributes:

Debug.Print dom.Get("Name")
Debug.Print dom.Get("whenCreated")

For more information about ADsPath, see Binding String. For more information about binding, see Binding to an ADSI Object.

Related topics

Creating an Organizational Unit

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)

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

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