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!
Thanks!
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
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Should look something like this though
ldapquerystring = "LDAP://" & DistName
ds.SearchRoot = New DirectoryEntry(ldapqueryst ring)
ds.PageSize = 1000
Dim dsResult As DirectoryServices.SearchRe sult
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-BillingCA I")
userDispN = objUser.Get("displayName")
outline = strName & "%" & userFN & "%" & userSN & "%" &
userDesc & "%" & userCAI & "%" & userBillCAI & "%" & userDispN & "%" &
DistName
WriteIt(outline)
End If
Next 'ObjUser
objContainer = GetObject(ldapquerystring)
Next 'Itercount
ldapquerystring = "LDAP://" & DistName
ds.SearchRoot = New DirectoryEntry(ldapqueryst
ds.PageSize = 1000
Dim dsResult As DirectoryServices.SearchRe
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-BillingCA
userDispN = objUser.Get("displayName")
outline = strName & "%" & userFN & "%" & userSN & "%" &
userDesc & "%" & userCAI & "%" & userBillCAI & "%" & userDispN & "%" &
DistName
WriteIt(outline)
End If
Next 'ObjUser
objContainer = GetObject(ldapquerystring)
Next 'Itercount
ASKER
kmichie, what references need to be imported in Visual Studio .net for your code to work?
System.DirectoryServices should be all you need
http://www.vbdotnetheaven.com/Sections/ActiveDirectory.asp