VB DirectoryService Guru... HELP???

G

Guest

Can someone please help!

I am trying to use DirectoryServices with a datagrid to show the different
users in our AD and then have a button that will show the details of the
selected user and give the ability to edit the users details!

I'm having a problem getting the users details to show up when you click a
button in the datagrid and would really appritiate help solving this...

The following article gives some guidance but it is in C#!
http://www.wimdows.net/articles/article.aspx?aid=13


Thanks...

...Inlinecode

<asp:ButtonColumn Text="<img border=0 src=../images/properties.gif alt=Page
Properties>" CommandName="dgADUserInfo_SelectedIndexChanged()">
<ItemStyle ForeColor="#3300FF"></ItemStyle>
</asp:ButtonColumn>



....Codebehind..
Sub GetUserADInfo()
Dim strADPath As String
strADPath = "netdomain.domain.dk"

Dim Entry As DirectoryEntry = New DirectoryEntry("LDAP://" &
strADPath, "administrator", "xxxxxx")
' Create a DirectorySearcher object.
Dim mySearcher As New DirectorySearcher(Entry)
' Use the FindOne method to find the object, which in this case, is
the user
' indicated by User Name and assign it to a SearchResult.
mySearcher.Filter = ("(&(objectCategory=person)(objectClass=user))")
'Dim MySearchResult As SearchResult = mySearcher.FindOne
Dim results As SearchResultCollection

results = mySearcher.FindAll()
dgADUserInfo.DataSource = results
dgADUserInfo.DataBind()

End Sub


Sub dgADUserInfo_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As DataGridCommandEventArgs)

Dim strADPath As String
strADPath = "netdomain.domain.dk"

Dim Entry As DirectoryEntry = New DirectoryEntry("LDAP://" &
strADPath, "administrator", "xxxxxx")
' Create a DirectorySearcher object.
Dim mySearcher As New DirectorySearcher(Entry)
' Use the FindOne method to find the object, which in this case,
is the user
' indicated by User Name and assign it to a SearchResult.
mySearcher.Filter =
("(&(objectCategory=person)(objectClass=user))(Name=dgADUserInfo.SelectedItem.Cells[1].Text))")

Dim result As Object
For Each result In mySearcher.FindAll()
TextBox1.Text = result.GetDirectoryEntry().Name

' Dim myEnumerator As IDictionaryEnumerator =
result.Properties.GetEnumerator()
' While myEnumerator.MoveNext()
' Console.WriteLine("{0}: {1}", myEnumerator.Key,
myEnumerator.Value)
'End While
Next
End Sub
 

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

Members online

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top