G
Guest
Hi can someone please tell me how I get the username only into a datagrid I
have created to show all the Active Directory Users! At the moment the only
thing I can get to appear in the datagrid is the AD path!
E.G:
<%# Container.DataItem.path%>
Can someone please advise...
I'm new to DirectoryServices and am trying to create a small app to edit
some of the users info in the AD... Any tips and good websites would be
really appritiated! Preferably in VB.NET
Thanks
' CODEBEHIND
Sub GetUserADInfo()
Dim strUserName As String
Dim strADPath As String
strUserName = "netadmin" 'HttpContext.Current.User.Identity.Name
strADPath = "netdomain.domain.dk"
Dim Entry As DirectoryEntry = New DirectoryEntry("LDAP://" &
strADPath, "username", "xxxxxxx")
' 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
have created to show all the Active Directory Users! At the moment the only
thing I can get to appear in the datagrid is the AD path!
E.G:
<%# Container.DataItem.path%>
Can someone please advise...
I'm new to DirectoryServices and am trying to create a small app to edit
some of the users info in the AD... Any tips and good websites would be
really appritiated! Preferably in VB.NET
Thanks
' CODEBEHIND
Sub GetUserADInfo()
Dim strUserName As String
Dim strADPath As String
strUserName = "netadmin" 'HttpContext.Current.User.Identity.Name
strADPath = "netdomain.domain.dk"
Dim Entry As DirectoryEntry = New DirectoryEntry("LDAP://" &
strADPath, "username", "xxxxxxx")
' 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