Jump to content

Help me troubleshoot


notta
 Share

Recommended Posts

Hey guys, I have a script at work that I've been working on that I'm having a problem with. It basically pops an inputbox asking for the machine name. Then it connects to the machine on the network and pulls the logged on user. Finally it searches the AD for the OU that the user resides in and returns their name. Now I wrote this for one of my co-workers and it works great on every machine that I tested it on, but it will not return the AD user name on his machine.

Any ideas why he cannot connect to the active directory provider on his machine? If I query the information with objget and hard code the adspath it pulls the information correctly, but the following fails.

$objConnection = ObjCreate("ADODB.Connection")
$objCommand =   ObjCreate("ADODB.Command")
$objConnection.Provider = "ADsDSOObject"
$objConnection.Open "Active Directory Provider"
$objCommand.ActiveConnection = $objConnection

If I log onto the machine I receive the same exact problem. The problem is definitely machine specific. Any ideas?

Edited by notta
Link to comment
Share on other sites

So what is different with that one machine? Is it running Vista while everybody else is running XP? What service packs are installed? Is active directory installed with everything that everybody else has? Does it have extras that could be interfering with operations? Are there any differences in the way active directory behaves on that computer compared to the others? These are the kinds of questions you need to ask to start tracking down why your program works on most computers and not on the one.

Edited by Nutster

David Nuttall
Nuttall Computer Consulting

An Aquarius born during the Age of Aquarius

AutoIt allows me to re-invent the wheel so much faster.

I'm off to write a wizard, a wonderful wizard of odd...

Link to comment
Share on other sites

Thanks for the replies guys. We have an AD admin tool on all of our machines and they work fine. All of our machine are XP SP2. No firewalls installed or at least not enabled. As I said this script works fine, just not on the one machine so it's not a problem with the code. As an example if I run the following on that machine it returns the name no problem:

$objUser = ObjGet _
    ("LDAP://cn=examplename,ou=someou,dc=ourdomain,dc=com")

msgbox(0,"","First Name: " & $objUser.displayname)

For some reason, using the adodb connection does not work on that machine.

Edited by notta
Link to comment
Share on other sites

I'm just troubleshooting here >_< but have you tried the script on a clean [Local] profile running the script with domain admin privileges.

I would give that a try first so delete c:\documents and settings\username (will requires reboot to delete) then login as that deleted user account so it creates a new ntusr,dat etc etc.

Also anything show up in event logs?

Edited by failedtocompile
Link to comment
Share on other sites

On that machine, the owner of the machine has the issue and when I log in I also get the same issue. I seriously doubt both of our profiles are corrupted >_< Thanks.

Also anything show up in event logs?

Good thought. I'll check tomorrow when I go in. Let me ask you something. Is there something special that needs to be added to an XP machine to make an ADODB.Connection? I mean can a brand new XP box run a script that can connect to AD and pull the info I'm trying to pull? I'm just thinking the machine is missing something to make the connection happen.

Edited by notta
Link to comment
Share on other sites

Well I tested about 10 more machines today and even had the guy log into another machine and the script worked fine. It's failing on his machine only. Here is the code where it's failing:

Func _findADS($username)
   $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=" & "'" & $username & "'"  
   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 
EndFunc

;*************************************

Link to comment
Share on other sites

Just in case anyone stumbles along this thread I figured out the problem. I converted the piece that was causing the problem back to VB and it gave me the exact error I needed.

Error: Provider cannot be found. It may not be installed properly

Source: ADODB Connection

I reinstalled MDAC and it resolved the issue.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...