Solved Using Recordset Data as If-Then Condition

pooldead

Registered User.
Local time
Today, 01:08
Joined
Sep 4, 2019
Messages
136
I have the following code setup to run code based on a certain condition:
Code:
Dim classOne as String, rs2 as ADODB.recordset

classOne = "top person organizationalPerson user"

If (rs2.Fields("objectClass").Value = classOne) Then
    <DO STUFF>
End If
I'm getting a type mismatch error against the If-Then line. My "rs2" recordset is populating data from Active Directory. I'm trying to figure out how I can say "if the objectClass in rs2 = what is provided from the classOne string, do stuff"....
 
I know nothing about AD, but wouldn't that be the class description.?

Have you even looked to see what is in ObjectClass?

Debug.Print
rs2.Fields("objectClass")

I am presuming there is a lot more code between the Dim and testing rs2 ?
 
I know nothing about AD, but wouldn't that be the class description.?

Have you even looked to see what is in ObjectClass?

Debug.Print
rs2.Fields("objectClass")

I am presuming there is a lot more code between the Dim and testing rs2 ?
Yes, there is a fair bit more code, however I have tested that objectClass does pull what I'm asking it to
 
Directly, at the moment, I can't say, b/c my code is stuck at the If-Then statement. The missing code above this however pulls the objectClass from AD and puts it in a table. I have to run different LDAP queries based on the objectClass, which is why I'm trying to specify this way. But I know the objectClass property itself works, because the table is accurately populated prior to this.
 
What type of field is ObjectClass in your recordset? Numeric?
 
Well I cannot help. sorry.
 
What type of field is ObjectClass in your recordset? Numeric?
This may have just answered my question, bc I'm dumb and wasn't paying attention. It pulls from AD as an array, and I typically use a Join() to convert it to string.....🤦‍♂️

I'll test and see if that fixes the problem
 

Users who are viewing this thread

Back
Top Bottom