![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | ADODB.Connection Problem. Need help troubleshooting. Hi, I wrote a script the other day at work that connects to a remote machine and gets the logged on user. Next it searches AD for the ADSPath. Finally I bind to the user account and return the user's name. This has worked great on every machine I've tried it on with the exception of one. I have narrowed the problem down to the machine. The owner of the machine cannot run it and if I log into his machine I get the same errror, but yet the same script works on every other machine. If I use the following it works fine which is showing the machine has rights and can connect to the AD. Set objUser = GetObject _ ("LDAP://cn=examplename,ou=someou,dc=ourdomain,dc=com") Wscript.Echo "First Name: " & objUser.displayname If I use this method it fails. I don't have the code with me, but hopefully you see what I'm trying to say. Set objConnection = CreateObject("ADODB.Connection") Set objCommand = CreateObject("ADODB.Command") objConnection.Provider = "ADsDSOObject" objConnection.Open "Active Directory Provider" objCommand.ActiveConnection = objConnection I'm wondering if the machine is missing something to be able to use ADODB.Connection. If I had a fresh XP machine and I used a script to connect to the AD provider would it work or do you need something special installed to connect? Any help would be appreciated. |
My System Specs![]() |
| | #2 (permalink) |
| | Re: ADODB.Connection Problem. Need help troubleshooting. "Dave" <Dave@xxxxxx> wrote in message news:1DD3D162-5F69-46E3-A017-48223B68F978@xxxxxx Quote: > Hi, I wrote a script the other day at work that connects to a remote > machine > and gets the logged on user. Next it searches AD for the ADSPath. Finally > I > bind to the user account and return the user's name. This has worked great > on > every machine I've tried it on with the exception of one. I have narrowed > the > problem down to the machine. The owner of the machine cannot run it and if > I > log into his machine I get the same errror, but yet the same script works > on > every other machine. > > If I use the following it works fine which is showing the machine has > rights > and can connect to the AD. > > Set objUser = GetObject _ > ("LDAP://cn=examplename,ou=someou,dc=ourdomain,dc=com") > Wscript.Echo "First Name: " & objUser.displayname > > If I use this method it fails. I don't have the code with me, but > hopefully > you see what I'm trying to say. > > Set objConnection = CreateObject("ADODB.Connection") > Set objCommand = CreateObject("ADODB.Command") > objConnection.Provider = "ADsDSOObject" > objConnection.Open "Active Directory Provider" > objCommand.ActiveConnection = objConnection > > > I'm wondering if the machine is missing something to be able to use > ADODB.Connection. If I had a fresh XP machine and I used a script to > connect > to the AD provider would it work or do you need something special > installed > to connect? Any help would be appreciated. the error. ADO can be used on any computer with MDAC installed. MDAC has come with every OS since Windows 2000. MDAC is installed on Windows 95/98 and NT when you install DSClient. It seems unlikely the problem computer does not support ADO. Also, I'm not aware of anything that would require a newer version of MDAC. You also don't say what OS is on the problem computer, or if anything is different about it. We will need to see more code and the error message (and the line the raises the error) to help more. -- Richard Mueller MVP Directory Services Hilltop Lab - http://www.rlmueller.net -- |
My System Specs![]() |
| | #3 (permalink) |
| | Re: ADODB.Connection Problem. Need help troubleshooting. Thanks for the reply Richard. The machine that is having the problem is a Windows XP with SP2. The code is converted from VB to autoit, but you get the gist. $name is the name passed to this function which is just the user's account name. ;---------------------------------------- $objConnection = ObjCreate("ADODB.Connection") $objCommand = ObjCreate("ADODB.Command") $objConnection.Provider = ("ADsDSOObject") $objConnection.Open("Active Directory Provider") $objCommand.ActiveConnection = $objConnection $objCommand.Properties("Page Size") = 1000 $objCommand.Properties("Searchscope") = 2 $objCommand.CommandText = _ "SELECT ADsPath FROM 'LDAP://dc=mydomain,dc=com' WHERE objectCategory='user' " & _ "AND name=" & "'" & $name & "'" if IsObj($objCommand) Then MsgBox(0,"", "is object") <-- returns that it is an object Else MsgBox(0,"", "not object") EndIf $objRecordSet = $objCommand.Execute $objRecordSet.MoveFirst ;************************************* MsgBox(0,"", "11e") ;<------ Makes it here $value = $objRecordSet.Fields("ADsPath").Value <--- Error MsgBox(0,"", "11f") <--- Never reaches this ;************************************* $objConnection.Close --------------------------------------------------------- I tried a few more machines today without problem except for the one machine I'm writing about. Any ideas? |
My System Specs![]() |
| | #4 (permalink) |
| | Re: ADODB.Connection Problem. Need help troubleshooting. "Dave" <Dave@xxxxxx> wrote in message news:035F726D-D90B-4D76-A860-DB40980E556A@xxxxxx Quote: > Thanks for the reply Richard. The machine that is having the problem is a > Windows XP with SP2. The code is converted from VB to autoit, but you get > the > gist. > > $name is the name passed to this function which is just the user's account > name. > > ;---------------------------------------- > > $objConnection = ObjCreate("ADODB.Connection") > $objCommand = ObjCreate("ADODB.Command") > $objConnection.Provider = ("ADsDSOObject") > $objConnection.Open("Active Directory Provider") > $objCommand.ActiveConnection = $objConnection > > $objCommand.Properties("Page Size") = 1000 > $objCommand.Properties("Searchscope") = 2 > > $objCommand.CommandText = _ > "SELECT ADsPath FROM 'LDAP://dc=mydomain,dc=com' WHERE > objectCategory='user' > " & _ "AND name=" & "'" & $name & "'" > if IsObj($objCommand) Then > MsgBox(0,"", "is object") <-- returns that it is an object > Else > MsgBox(0,"", "not object") > EndIf > > $objRecordSet = $objCommand.Execute > $objRecordSet.MoveFirst > ;************************************* > MsgBox(0,"", "11e") ;<------ Makes it here > $value = $objRecordSet.Fields("ADsPath").Value <--- Error > MsgBox(0,"", "11f") <--- Never reaches this > ;************************************* > > $objConnection.Close > > > --------------------------------------------------------- > > I tried a few more machines today without problem except for the one > machine > I'm writing about. Any ideas? and you want help with "it doesn't work", and you think a VBScript (different from VB and AutoIt) newsgroup is a good place to ask? Maybe you should convert the relevant section of code to VBScript, get it working on the machines where your AutoIt code works, and then try it on the non-working machine and report the complete error message. That would convey way more info than "it doesn't work" and we would have more knowledge of your code than "you get the gist". -Paul Randall |
My System Specs![]() |
| | #5 (permalink) |
| | Re: ADODB.Connection Problem. Need help troubleshooting. > Are you saying that the code was originally VB, and was converted to AutoIt, Quote: > and you want help with "it doesn't work", and you think a VBScript > (different from VB and AutoIt) newsgroup is a good place to ask? > > Maybe you should convert the relevant section of code to VBScript, get it > working on the machines where your AutoIt code works, and then try it on the > non-working machine and report the complete error message. That would > convey way more info than "it doesn't work" and we would have more knowledge > of your code than "you get the gist". Sorry about that. Here is the code converted back to VB. --------------------------------------------------------------------------------- username = "myname" Set objConnection = CreateObject("ADODB.Connection") Set objCommand = CreateObject("ADODB.Command") objConnection.Provider = ("ADsDSOObject") objConnection.Open("Active Directory Provider") objCommand.ActiveConnection = ObjConnection objCommand.Properties("Page Size") = 1000 objCommand.Properties("Searchscope") = 2 objCommand.CommandText = _ "SELECT ADsPath FROM 'LDAP://dc=mydomain,dc=com' WHERE " & _ "objectCategory='user'" & _ "AND name='" & username & "'" Set objRecordSet = objCommand.Execute objRecordSet.MoveFirst Wscript.Echo objRecordSet.Fields("ADsPath").Value objConnection.Close --------------------------------------------------------------------------------- This VB script works fine on my machine, but again it doesn't work on my co-workers. I receive the following error: Line: 6 Char: 1 Error: Provider cannot be found. It may not be installed properly Code: 800A0E7A Source: ADODB.Connection The machine is running the same exact version of MDAC as I am. Again the machine is a Windows XP SP2 32 bit. Any help would be appreciated. |
My System Specs![]() |
| | #6 (permalink) |
| | Re: ADODB.Connection Problem. Need help troubleshooting. Well converting the file back to VB gave me the error I needed to resolve the issue. Re-installing MDAC fixed the issue. Thanks for the help guys. |
My System Specs![]() |
| | #7 (permalink) |
| | Re: ADODB.Connection Problem. Need help troubleshooting. "Dave" <Dave@xxxxxx> wrote in message news:AF901C00-D6E3-4A56-A5B8-2FAE9CD4423E@xxxxxx Quote: > Well converting the file back to VB gave me the error I needed to resolve > the > issue. Re-installing MDAC fixed the issue. Thanks for the help guys. I often find that doing the work to give people the info needed to help me, soon leads me to the solution. -Paul Randall |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Using SUM with ADODB object | VB Script | |||
| Using ADODB | VB Script | |||
| Troubleshooting Internet Connection | Vista networking & sharing | |||
| ADODB: com and .net | PowerShell | |||
| Powershell 32 vs. 64 when using ADODB | PowerShell | |||