Link to home
Create AccountLog in
Avatar of remorknevets
remorknevets

asked on

IADS in vb.net

How can I use IADS to access and manipulate active directory in visual studio using vb.net, this was so easy using visual studio 6.0....

Thanks!
Avatar of kamichie
kamichie

VB.NET has integrated Active Directory Handling, meaning you just need to put in a few imports, and use the appropriate objects. I'm posting a link to a simple tutorial that should help out.

http://www.vbdotnetheaven.com/Sections/ActiveDirectory.asp
Avatar of remorknevets

ASKER

How can I enumerate all users using directory services in vb.net?  I know how to use the LDAP path to display and update attributes for a specific user, but how can I move through the users in LDAP?  ie, a next button...
ASKER CERTIFIED SOLUTION
Avatar of kamichie
kamichie

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Should look something like this though

ldapquerystring = "LDAP://" & DistName

ds.SearchRoot = New DirectoryEntry(ldapquerystring)
ds.PageSize = 1000

Dim dsResult As DirectoryServices.SearchResult

i1 = ds.FindAll.Count
iterations = i1 / 1000

For iterCount = 1 To iterations
objContainer = GetObject(ldapquerystring)
For Each objUser In objContainer
i1 = 0 'reset the test value
strName = objUser.Name
i1 = strName.Length
If i1 > 0 Then
strDesc = objUser.Description
userFN = objUser.Get("givenName")
userSN = objUser.Get("sn")
userDesc = objUser.Get("description")
userCAI = objUser.Get("cvx-cai")
userBillCAI = objUser.Get("cvx-BillingCAI")
userDispN = objUser.Get("displayName")
outline = strName & "%" & userFN & "%" & userSN & "%" &
userDesc & "%" & userCAI & "%" & userBillCAI & "%" & userDispN & "%" &
DistName
WriteIt(outline)
End If
Next 'ObjUser
objContainer = GetObject(ldapquerystring)
Next 'Itercount
kmichie, what references  need to be imported in Visual Studio .net for your code to work?
System.DirectoryServices should be all you need