[Active Directory] best protocols

R

RTT

does anyone has axperience with accessing AD information through VB.Net. Is
the best protocol LDAP? does anyone has a site for information about AD and
VB.Net cause it's the first time i have to work with active directory in
vb.net so all sources of information would be helpfull. Thanks
 
D

Daniel

AFAIK, the only protocol is LDAP. You need to add a reference to Active DS
i believe.

Then use:

Dim oContainer As IADsContainer
Dim oUser As IADsUser

oContainer = GetObject
"LDAP://sluibericaa.sluiberica.slu.edu/CN=Users,OU=Students,OU=UsersHierarchy,DC=sluiberica,DC=slu,DC=edu")

oUser = oContainer.Create("user", "CN=" & "SmithA")
oUser.FirstName = "Alan"
oUser.LastName = "Smith"
oUser.SetInfo


This is an example. Obviously you need to set more properties!
 
D

Daniel

AFAIK, the only protocol is LDAP. You need to add a reference to Active DS
i believe.

Then use:

Dim oContainer As IADsContainer
Dim oUser As IADsUser

oContainer = GetObject
LDAP://DNSDOMAINNAME/CN=Users,OU=EMPLOYEES,,DC=mydomain,,DC=com)

oUser = oContainer.Create("user", "CN=" & "SmithA")
oUser.FirstName = "Alan"
oUser.LastName = "Smith"
oUser.SetInfo


This is an example. Obviously you need to set more properties!
 
P

Paul Clement

¤ AFAIK, the only protocol is LDAP. You need to add a reference to Active DS
¤ i believe.
¤

The WinNT provider is also available for both NT and AD domains. Sometimes it's much easier to use
but is considerably less capable.


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
R

RTT

For the moment i can read through a hierachie of the AD by browsing bye the
use of LDAP:// strings

Now i can get to the level of finding the string of a user
LDAP://CN=BlendemanDirk,OU=Users,OU=Antwerp,OU=BE,OU=SE,DC=be,DC=domain,DC=w
e
but now the problems is, how do i find date about the users. I Would like to
retrieve his emailaddress and the groups his in.

Does anyone know a way?

or a simple way to find a user in the active directory, or to find a group
and retrieving it's users...

thxs in advance
 
P

Paul Clement

¤ For the moment i can read through a hierachie of the AD by browsing bye the
¤ use of LDAP:// strings
¤
¤ Now i can get to the level of finding the string of a user
¤ LDAP://CN=BlendemanDirk,OU=Users,OU=Antwerp,OU=BE,OU=SE,DC=be,DC=domain,DC=w
¤ e
¤ but now the problems is, how do i find date about the users. I Would like to
¤ retrieve his emailaddress and the groups his in.
¤
¤ Does anyone know a way?
¤
¤ or a simple way to find a user in the active directory, or to find a group
¤ and retrieving it's users...
¤

The following code should help:

Public Function GetUserInfo(ByVal UserID As String)

Dim RootDSE As New DirectoryServices.DirectoryEntry("LDAP://RootDSE")
Dim DomainDN As String = RootDSE.Properties("DefaultNamingContext").Value
Dim ADEntry As New DirectoryServices.DirectoryEntry("LDAP://" & DomainDN)
Dim ADSearch As New System.DirectoryServices.DirectorySearcher(ADEntry)

If UserID = "" Then
UserID = System.Security.Principal.WindowsIdentity.GetCurrent.Name.Split("\"c)(1)
End If

Dim ADSearchResult As System.DirectoryServices.SearchResult
ADSearch.PropertiesToLoad.Add("memberOf")
ADSearch.Filter = ("(samAccountName=" & UserID & ")")
ADSearch.SearchScope = SearchScope.Subtree
Dim UserFound As SearchResult = ADSearch.FindOne()
Dim propertyCount As Integer = UserFound.Properties("memberOf").Count
If Not IsNothing(UserFound) Then
Console.WriteLine(UserFound.GetDirectoryEntry().Properties.Item("mail").Value)
Dim propertyCounter As Integer
Dim dn As String

For propertyCounter = 0 To propertyCount - 1

dn = CType(UserFound.Properties("memberOf")(propertyCounter), String)
Console.WriteLine(dn.ToString)
Next
End If

End Function


Paul
~~~~
Microsoft MVP (Visual Basic)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top