Setting Up the Microsoft Visual Studio 2010 Development Environment For Visual Basic
-
Start Visual Studio 2010.
-
Create a new Visual Basic project.
-
Add a reference to the Active DS Type Library.
[!Note]
If you do not require early COM object binding, ignore this step.- Select Project | Add Reference.
- Select the COM tab.
- Select Active DS Type Library.
-
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
-
Follow the previous steps to create a standard executable Visual Basic project.
-
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 -
Press <F5> to run the program.
-
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.
