Jump to content
Sign in to follow this  

Close then Open LDAP Query

Recommended Posts


hi all. i'm using the adfunctions posted somewhere here. thanks for that function. they are really helpful for querying AD info. i have question using this.

i have a TCP server which accepts clients connections. Client will send info with the currently loggedon user. integrated the adfunctions on the TCP server to query the Full Display Name of the user who successfully connect. For the first client connection, i am retreiving the Full Name of the user and was working fine. But for the second client connection, the script freezes and could not query the user information. is it possible for the function to close the LDAP query then open it again for another query for the next client. i am thinking to use this line to close then re-open the LDAP query.

$objConnection.Close("Active Directory Provider")
- to close the LDAP query

$objConnection.Open("Active Directory Provider")
- to open and to re-use next LDAP query

the script is pointing to this function with error

If $objRecordSet.RecordCount = 1 Then

Func _ADObjectExists($object)
    $strQuery = "<LDAP://" & $strHostServer & "/" & $strDNSDomain & ">;(sAMAccountName=" & $object & ");ADsPath;subtree"
    $objRecordSet = $objConnection.Execute($strQuery); Retrieve the FQDN for the group, if it exists
    If $objRecordSet.RecordCount = 1 Then
        $objRecordSet = 0
        Return 1
        $objRecordSet = 0
        Return 0

Any idea why the script hangs? Or only one query is allowed?

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this