LDAP Query to search a user in AD using his partial last name

Dim User as object
Set User = GetUserObjectFromPartialName(‘doe’)
Msgbox User.FullName & User.sAMAccountName
—————————————————————————————————-

Public Function GetUserObjectFromPartialName(ByVal PartialName As String) As Object
On Error Resume Next
Set rs = CreateObject(“adodb.recordset”)
rs.ActiveConnection = “provider=adsdsoobject”

rs.Open “<LDAP://dc=sl,dc=ad,dc=csx,dc=com>;(&(objectCategory=Person)” & _
“(objectClass=OrganizationalPerson)(name=” & PartialName & “*));adspath;subtree”
If Not rs.EOF Then
Set GetUserObjectFromPartialName = GetObject(rs(0))
End If
End Function

Recursive LDAP function to get nested groups

Here is a simple recursive function that I wrote which will give you nested groups and members for any given Active Directory group. Try it….it works! U can bind it to a tree later on to show it on the screen. I have also included an output of how it looks when bound to an [...]