Error applying to attribute with hifen in LDAP name in Windows 8

There is a VB6 application that uses ADODB to connect to LDAP and do a lot of operations, there is an LDAP Attribute (field) called "co-unit" and when the application runs specifically on Windows 8 (it has been tested on other OSs and works 100%) generates an "Unspecified error (-2147467259)" error and after analyzing the source code it was discovered that the problem is that when trying to run the Querye it does not accept any field that contains in its name the hyphen, for example co-unit , no-drive, dt-creation, etc ...

I have already searched in numerous forums including MVPs and other professionals but I have not been able to find any solution, because it seems that this problem should never have occurred.

I would like to know if there is anyone who can help me and give a light to solve this problem, I have tried everything, changed components, tried to get the Attribute through ADSPath among other ways and none gave result giving the same error.

You are my last attempt to help.

I'm waiting for some help from someone.

Excerpt from code that generates error:



sqlStmt = "SELECT uid, co-unit, cn" & _
    "FROM 'LDAP: //" & m_LDAPServer & ":" & m_LDAPPort & "/ o =" & m_Org & "/ ou =" & m_OrgPeople &
    "WHERE uid = '" & m_User & "'" & "and objectClass = '*'"
   
    'executes the data string ...
    Err.Clear
    Set rs = con.Execute (sqlStmt) 'IN THIS POINT IT GENERATES ERROR, BECAUSE IT DOES NOT ROLL THE STRING, ONLY IF I REMOVE THE FIELD co-unit BUT I NEED THIS FIELD FOR THE CONTINUITY OF THE OPERATION THAT THE SYSTEM DOES.
Maurício MachadoEspecialista de TecnologiaAsked:
Who is Participating?
 
Chris WatsonSoftware DeveloperCommented:
Can you wrap the field name in square brackets?

sqlStmt = "SELECT uid, [co-unit], cn" & _
    "FROM 'LDAP: //" & m_LDAPServer & ":" & m_LDAPPort & "/ o =" & m_Org & "/ ou =" & m_OrgPeople &
    "WHERE uid = '" & m_User & "'" & "and objectClass = '*'"

Open in new window

0
 
Shaun VermaakTechnical Specialist/DeveloperCommented:
Try \-

Will check my old code, had this issue years ago
0
 
Maurício MachadoEspecialista de TecnologiaAuthor Commented:
Thank you very much, your response helped me a lot in solving the problem.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.