Directory Services

Setting Up Visual Basic 6.0 for ADSI Development

Setting Up the Microsoft Visual Basic 6.0 Development Environment

  1. Start Visual Basic 6.0.
  2. Select the type of project you would like to create.
  3. Select Project | References and ensure that the Active DS Type Library is selected, as shown in the figure below. If you do not require early COM object binding, ignore this step.
  4. Begin programming with ADSI.
project references window

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

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

  1. Follow the previous steps to create a standard executable VB 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 program is used to set the FullName and Description
    '------------------------------------------------------------
    Dim usr As IADsUser
    
    ' Binding 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 6.0, see Accessing Active Directory Using Visual Basic.