Posts

Showing posts from March, 2009

BIND AD to DataGrid

To bind the Active Directory to a datagrid I have built two functions. The first one is called either on pageload or button click or whenever you want it to happen: (Watch for wrapping) Private Function CheckAD() Dim objRootDSE = GetObject( ldap://RootDSE/ ) Dim adPath As String = "LDAP://" & Mid(objRootDSE.Get("DefaultNamingContext"), InStr(objRootDSE.Get("DefaultNamingContext"), "DC=") + 3, InStr(objRootDSE.Get("DefaultNamingContext"), "," ) - 1 - 3) Dim adAuth As LDAPAuthenticate = New LDAPAuthenticate(adPath) dgLdap.DataSource = LDAPAuthenticate.LoadADList(adPath) dgLdap.DataBind() End Function The second one actually connects to the Active Directory and returns a list of the searched properties: Public Shared Function LoadADList(ByVal pathsent As String) As List(Of LDAPAuthenticate) Dim result As SearchResultCollection = Nothing Dim entry As DirectoryEntry = New DirectoryEntry(pathsent, "testuser", "