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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Shaun VermaakTechnical SpecialistCommented:
Try \-

Will check my old code, had this issue years ago
0
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Maurício MachadoEspecialista de TecnologiaAuthor Commented:
Thank you very much, your response helped me a lot in solving the problem.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows 8

From novice to tech pro — start learning today.