Hello all,
I am developing a .Net Web Application / Active Directory application. I am attempting to connect to AD, search for a user and return LDAP properties. I am able to do all of this with the code below. To display the information I am trying to output the results in a web page. At the moment I am trying to create a table and output a desctiption of what the LDAP propery is - for example Username, Email Address followed by the LDAP value. I would like to create a table with two cells in each row, the first containing the description and the second containing the LDAP value. This is where I am having difficulty. I have only been able to successfully loop through the LDAP values and put the results in a table with one cell per row.
This is the code I currently have:
Dim rootEntry As New DirectoryEntry("LDAP://DC=Domain,DC=Com") Dim searcher As New DirectorySearcher(rootEntry) searcher.PropertiesToLoad.Add("cn") searcher.PropertiesToLoad.Add("mail") searcher.PropertiesToLoad.Add("distinguishedName") searcher.PageSize = 5 searcher.ServerTimeLimit = New TimeSpan(0, 0, 30) searcher.ClientTimeout = New TimeSpan(0, 10, 0) searcher.Filter = "(&(anr=bbrazil)(objectCategory=person))"
Dim strDistinguishedName As String Dim strMail As String Dim strCN As String
Dim results As SearchResultCollection results = searcher.FindAll() Dim result As SearchResult
Dim rowCounter As Integer Dim rowCount As Integer Dim cellCounter As Integer Dim cellCount As Integer Dim i As Integer
For Each result In results strDistinguishedName = result.Properties("distinguishedName")(0) strMail = result.Properties("mail")(0) strCN = result.Properties("cn")(0) Next
Dim ADFields() As String ADFields = New String() {strDistinguishedName, strMail, strCN}
Dim ADFieldsDescription() As String ADFieldsDescription = New String() {"Distinguished Name", "Mail", "CN"}
I have created arrays to hold the AD Fields and the AD Field Description.
Any help with creating the table to view the results would be most appreciated. Also, is using a table the correct way to display information like this?
Thanks,
Ben