0

I have the following:

Set objDomain = GetObject ("GC://RootDSE")
objADsPath = objDomain.Get("defaultNamingContext")
'response.write(objADsPath)
Set objDomain = Nothing
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.provider ="ADsDSOObject"
objConn.Properties("User ID") = "USER" 'domain account with read access to LDAP
objConn.Properties("Password") = "PASS" 'domain account password
objConn.Properties("Encrypt Password") = True
objConn.open "Active Directory Provider"
Set objCom = CreateObject("ADODB.Command")
Set objCom.ActiveConnection = objConn
objCom.CommandText ="select sAMAccountName as id, mail, sAMAccountName as label, sAMAccountName as value FROM 'GC://"+objADsPath+"' where sAMAccountname = '*"&Request.QueryString("term")&"*' ORDER by sAMAccountname"

I presumed I could alias the column names like I would do in SQL but it fails. Is it possible to do?

pee2pee
  • 3,619
  • 7
  • 52
  • 133
  • 1
    Don't assume because you can do it in SQL you can do it in WQL, they are different. If you are unsure what you can do read the [official documentation](https://learn.microsoft.com/en-us/windows/win32/wmisdk/wql-sql-for-wmi). – user692942 Mar 19 '21 at 15:05
  • 2
    Does this answer your question? [WQL Query and displaying custom fields](https://stackoverflow.com/questions/18448255/wql-query-and-displaying-custom-fields) – user692942 Mar 19 '21 at 15:07
  • The answers don't help/work unfortunately but will do some more reading – pee2pee Mar 19 '21 at 15:19
  • _it fails_ means it errors? – Flakes Mar 19 '21 at 15:49
  • Yes that is right. Apparently one can't do an alias. Other is to do SQL via LDAP but there's authentication issues... – pee2pee Mar 19 '21 at 15:54
  • 1
    The answer is just plain wrong, sorry for linking that...just saw the tick. Let's be clear, you cannot use an alias in a WQL query. – user692942 Mar 19 '21 at 15:59
  • Dang - thanks for trying – pee2pee Mar 19 '21 at 16:15

0 Answers0