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

Modifying an ADSI Object from ADO

· 52CE 我爱测

ADSI for Windows 2000 and DS Client includes a read-only OLE DB provider. This means that you cannot, at present, issue the UPDATE statement in the SQL dialect.

ADSI for Windows 2000 and DS Client includes a read-only OLE DB provider. This means that you cannot, at present, issue the UPDATE statement in the SQL dialect.

To modify an object returned from an ADO query

  1. Request the ADsPath when specifying an attribute name, as in "SELECT ADsPath, ..."
  2. Execute the query and get the ADsPath attribute.
  3. Bind to the record set using ADsPath, and modify the attributes.

The following code example shows how to modify an ADSI object after performing the steps outlined in the preceding example.

Dim Con As New Connection
Dim rs As New Recordset
Dim command As New Command
Dim usr As IADsUser

' Replace department for all users in OU=sales.
Set con = Server.CreateObject("ADODB.Connection")
con.Provider = "ADsDSOObject"
 
Set command = CreateObject("ADODB.Command")
Set command.ActiveConnection = con
 
command.CommandText = "SELECT AdsPath, cn FROM 'LDAP://OU=Sales,DC=Fabrikam,DC=com' WHERE objectClass = 'user'"
 
command.Properties("searchscope") = ADS_SCOPE_ONELEVEL
Set rs = command.Execute
While Not rs.EOF
    Set usr = GetObject(rs.Fields("AdsPath").Value)
    usr.Put "department", "1001"
    usr.SetInfo
    rs.MoveNext
Wend

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)

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

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