Home
Explore
Tags
Contribute
Home
»
VB.NET
»
VISUAL BASIC LANGUAGE
Working with Directory Services in VB.NET: Part 2
Posted in
VB.NET
|
VISUAL BASIC LANGUAGE
on
November 08, 2019
Tags:
Directory Services
,
Directory Services in VB.NET
,
VB.NET
In this article I will explain you about Working with Directory Services in VB.NET.
4936
Second part of my last article see
part 1
You can use Active Directory Users and Computers MMC to manage your Active Directory resources. It resides on the Administrative Tools menu on Windows 2000 servers.
The code in Listing 21.26 searches the MCBCorp.Com Windows 2000 Active Directory domain. It outputs all of the Active Directory objects and their properties, and then all the data inside, recursively.
Listing 21.26: Using DirectoryEntry (ldapdir1.vb)
Imports
System.DirectoryServices
Class
Test
Dim
instance
As
DirectoryServicesCOMException
Shared
Sub
Main(
ByVal
args
As
String
())
' the name of the domain
Dim
entry
As
New
DirectoryEntry(
"LDAP://MCBcorp, DC=com"
)
Console.WriteLine(
"Name = "
+ entry.Name)
Console.WriteLine(
"Path = "
+ entry.Path)
Console.WriteLine(
"SchemaClassName = "
+ entry.SchemaClassName)
Console.WriteLine(
"Properties:"
)
Console.WriteLine(
"====================================="
)
For
Each
key
As
String
In
entry.Properties.PropertyNames
Try
Console.WriteLine(vbTab & key &
" = "
)
For
Each
objCollection
As
[Object]
In
entry.Properties(key)
Console.WriteLine(vbTab & vbTab & Convert.ToString(objCollection))
Next
Console.WriteLine(
"==================================="
)
Catch
End
Try
Next
Dim
mySearcher
As
New
System.DirectoryServices.DirectorySearcher(entry)
mySearcher.Filter = (
"(objectClass=*)"
)
Console.WriteLine(
"Active Directory Information"
)
Console.WriteLine(
"====================================="
)
For
Each
resEnt
As
System.DirectoryServices.SearchResult
In
mySearcher.FindAll()
Try
Console.WriteLine(resEnt.GetDirectoryEntry().Name.ToString())
Console.WriteLine(resEnt.GetDirectoryEntry().Path.ToString())
Console.WriteLine(resEnt.GetDirectoryEntry().NativeGuid.ToString())
Console.WriteLine(
"==================================="
)
Catch
End
Try
Next
End
Sub
End
Class
You can create entries and properties in the Active Directory. You simply create a new directory or use an existing one with the DirectoryEntry class and then assign the values you want to the specific properties. When you have finished assigning the values, call the CommitChanges() method to cause the changes to occur in the Active Directory. The sample code in Listing 21.27 achieves this update operation.
Listing 21.27 also shows you how to pick individual properties of Active Directory objects! The properties term of Active Directory is not related to the VB.NET class properties used with get and set. Active Directory properties are an array of adjustable object property members with specific names determined by the Active Directory schema. For example, you can set the following properties for objects: sn, givenName, title, or mycustomproperty. The properties change depending on their class definition in the Active Directory schema. Refer to the Active Directory Schema MMC to discover possible object types and definitions.
Listing 21.27: Updating Active Directory
// get the handle to MCBuser from Active Directory database
Dim
entry
As
New
DirectoryEntry(
"LDAP://DC=MyDC, O=MyOrg, OU=MyOU, cn=MCBuser"
)
entry.Password =
"mcb"
// password
(entry.Properties(
"myprop"
)(0)) =
"myvalue"
// properties
entry.CommitChanges()
Conclusion
Hope this article would have helped you in understanding Working with Directory Services in VB.NET.
Related Articles
Working with Directory Services in VB.NET: Part 1
Web Services and ASP.NET in VB.NET
Start or Stop a Windows Service using VB.NET
Files and Directories in VB.NET
Enumerate Directory Using VB.NET
How To Get Root Directory Using VB.NET
Discovery of Web Services
Delete Directory Using VB.NET
How To Move a Directory Using VB.NET
Web Services and ASP.NET using VB language: Part 2
Categories
ACTIVE DIRECTOTRY IN VB.NET
ALGORITHMS AND VB.NET
ARRAY IN VB.NET
ASP.NET AJAX IN VB.NET
ASP.NET USING VB.NET
ASSEMBLIES IN VB.NET
COM INTEROP IN VB.NET
CRYPTOGRAPHY IN VB.NET
CRYSTAL REPORTS IN VB.NET
DATABASE & DBA
DEPLOYMENT IN VB.NET
DESIGN & ARCHITECTURE
DIRECTX WITH VB.NET
ENTERPRISE DEVELOPMENT
FILE IN VB.NET
GAMES IN VB.NET
GDI+ IN VB.NET
GENERAL
LINQ WITH VB.NET
MOBILE DEV IN VB.NET
MULTITHREADING IN VB.NET
NETWORKIN WITH VB.NET
OFFICE AND VB.NET
PRINTING IN VB.NET
REMOTING IN VB.NET
REPORTS IN VB.NET
SECURITY IN VB.NET
SILVERLIGHT USING VB.NET
Speech in VB.NET
STRING IN VB.NET
TABLET PC
VB.NET ADO.NET
VB.NET ARTICLE
VB.NET EXCEPTION HANDLING
VB.NET FAQ
VB.NET HOW DO I
VB.NET LANGUAGE
VB.NET TUTORIALS
VB.NET WINDOWS SERVICES
VBA
VISUAL BASIC 10
VISUAL BASIC LANGUAGE
WCF WITH VB.NET
WEB CONTROL IN VB.NET
WEB DEV IN VB.NET
WEB FORM WITH VB.NET
WEB SERVICES IN VB.NET
WINDOWS CONTROLS
WINDOWS FORMS IN VB.NET
WORKFLOW IN VB.NET
WPF IN VB.NET
XAML IN VB.NET
XML IN VB.NET
More Articles
Algorithm Generate Fibonacci Series in VB.NET
Algorithm - Factorial of an Number in VB.NET
Algorithm Quadrant in VB.NET
Algorithm Circular Queue in VB.NET
Algorithm Queues in VB.NET
Algorithm Stack in VB.NET
Algorithm Concept in VB.NET
How to use .NET Assemblies in VB.NET
How to create assembly in VB.NET
VB.NET Create Instance of a Type Dynamically
Select and Delete Ink in Tablet PC in VB.NET
Using Tablet PC Ink on Windows Controls in VB.NET
Tablet PC Frequently Asked Question in VB.NET
Setting Ink Overlay Properties in Tablet PC in VB.NET
VB.NET Advanced Controls of Mobile Internet
MediaElement control in Windows Phone 7
Image Brush Background set in Windows Phone 7
Mobile Mail sending Application in ASP.NET using VB.NET
Mobile Banking Application in ASP.NET using VB
I-MODE Client and Mobile Programming in VB.NET
Basic User Interface Controls of Mobile Internet in VB.NET
Basics of the Mobile Internet Toolkit using VB.NET
A glance at .NET Framework 3.0 in VB.NET
Reflection in VB.NET
Custom Exception Handling in VB.NET
Exception Handling in VB.NET
Inheritance in VB.NET
Retrieving Environment Variables in VB.NET
Introduction of Visual Studio 2008 in VB.NET: Part 1
VB.NET Select statement in SQL query
Dialog Box in VB.NET
Windows Registry in VB.NET
Get Current Time Zone in VB.NET
VB.NET Balloon Tooltip
Binding a ComboBox in VB.NET
Image as Button Background in VB.NET
Button State in VB.NET
Operating System Version in VB.NET
How many users are using the site at a same time?
BorderThickness Value in WPF
VB.NET display data in the FormView control
Add Web Server Controls to a PlaceHolder control at run time
DropDownList control through data binding in VB.NET
DropDownList control that contains items in VB.NET
How do I open a URL in a new Browser Window in ASP.NET?
Display an XmlNode contents in a DataGrid?
Delete a directory in VB.NET
Create and Save Bitmap Image in VB.NET?
VB.NET Constants
Variables in VB.NET
© 2020 DotNetHeaven. All rights reserved.
TERMS & CONDITIONS
|
CONTACT US
|
REPORT ABUSE