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

Setting Up Visual Basic 6.0 for ADSI Development

· 52CE 我爱测

This topic discusses how to set up Visual Basic in Visual Studio to develop an ADSI application.

Setting Up the Microsoft Visual Studio 2010 Development Environment For Visual Basic

  1. Start Visual Studio 2010.

  2. Create a new Visual Basic project.

  3. Add a reference to the Active DS Type Library.

    [!Note]
    If you do not require early COM object binding, ignore this step.

    1. Select Project | Add Reference.
    2. Select the COM tab.
    3. Select Active DS Type Library.
  4. Begin programming with ADSI.

Before you begin, log on to a Windows domain. You must have permission to modify the Active Directory database. By default, the Administrator has this privilege.

A Sample Visual Basic 6.0 Application: Modifying FullName and Description for a User

  1. Follow the previous steps to create a standard executable Visual Basic project.

  2. Double-click the Form. In Form_Load, type the following. You must replace the "LDAP://CN=jeffsmith,CN=users,DC=fabrikam,DC=com" string with the ADsPath of an existing user in a container in your domain. Create a test user account that can be modified for this purpose.

    '------------------------------------------------------------
    ' This code example is used to set the FullName and Description
    '------------------------------------------------------------
    Dim usr As IADsUser
    
    ' Bind to a user object.
    Set usr = GetObject("LDAP://CN=jeffsmith,CN=users,DC=fabrikam,DC=com")
    
    usr.FullName = "Jeff Smith"
    usr.Description = "A user for fabrikam.com" 
    usr.SetInfo ' Commit the changes to the directory
    
  3. Press <F5> to run the program.

  4. To verify changes, use the Active Directory Users and Computers management tool. For more information about using ADSI and Visual Basic, see Accessing Active Directory Using Visual Basic.

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)

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

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