COMatePlus and Active Directory

Developed or developing a new product in PureBasic? Tell the world about it.
blackborg
User
User
Posts: 38
Joined: Thu Nov 02, 2006 8:20 pm

COMatePlus and Active Directory

Post by blackborg »

I am trying to perform a search of active directory and followed the example file.

this produces the message that the adodb.recordset object could not be created

Here is the code..

Code: Select all

;/////////////////////////////////////////////////////////////////////////////////
;***COMate***  COM automation through iDispatch.
;*===========
;*
;*ADO demo.  Based on a PureDispHelper example by Kiffi.
;*Create and read a MDB database.
;/////////////////////////////////////////////////////////////////////////////////

XIncludeFile "adoconstants.pbi"

IncludePath "..\..\"
XIncludeFile "COMatePLUS.pbi"

OpenConsole()

 #ADS_CHASE_REFERRALS_EXTERNAL = 40;//parseInt('40',16);
; 	
; 		// Create connection object
; 	var _conn = new ActiveXObject("ADODB.Connection")	
; 
; 		// Create command object	
; 	var _com = new ActiveXObject("ADODB.Command");
; 	
; 		// Prepare connection object For use
; 	_conn.Provider = "ADsDSOObject";
; 	_conn.Open("Active Directory Provider");
; 	
; 		// Prepare command object For use
; 	_com.ActiveConnection = _conn;		
; 	_com.Properties("Page Size") = 100;
; 	_com.Properties("Timeout") = 60;
; 	_com.Properties("Searchscope") = 2;
; 	_com.Properties("Cache Results") = false;  // Do not cache the result set.	
; 	_com.Properties("Chase referrals") = ADS_CHASE_REFERRALS_EXTERNAL;


Define.COMateObject  adoConnection, adoRecordSet,adoCommand,ocomm2

;Create a new MDB database.
;==========================
  
  connectionString$ = "Active Directory Provider"


    adoConnection = COMate_CreateObject("ADODB.Connection")
    adoCommand = COMate_CreateObject("ADODB.Command")
    adoRecordSet = COMate_CreateObject("ADODB.RecordSet")
    
    If adoConnection
      adoConnection\SetProperty("Provider = 'ADsDSOObject'")
      If adoConnection\Invoke("Open('" + connectionString$ + "')") = #S_OK
        ;Insert some records.
        ;Note that since the SQL statement is to contain single quotes (which will interfere with COMate), we must use
        ;the $0027 escape sequence instead.
          SQL$ = "<LDAP://dc=domain1,dc=domain2,dc=domainSuffix>;(&(objectClass=user)(cn=*));cn,dn,adsPath;subtree"
        If COMate_GetLastErrorCode() = #S_OK
            
            adoCommand\SetProperty("ActiveConnection = " + Str(adoConnection) + " as COMateObject")

            ;put command options
            ;_com.Properties("Searchscope") = 2;
            
            adoCommand\SetProperty("CommandText = '" + SQL$ + "'")
            
            ;sqlCheck$ = adoCommand\GetStringProperty("CommandText")
            
            
            adoRecordSet = adoCommand\GetObjectProperty("Execute()")
            err$ = COMate_GetLastErrorDescription()
          If adoRecordSet
            rcount = adoRecordSet\GetIntegerProperty("RecordCount")
            Debug(rcount)
            Repeat
              EOF = adoRecordSet\GetIntegerProperty("EOF")
              If EOF = -1  ;Variant_TRUE
                Debug("bullshit")
                Break
              EndIf
              
              cn$ = adoRecordSet\GetStringProperty("Fields('cn')\Value")
              dn$ = adoRecordSet\GetStringProperty("Fields('dn')\Value")
              adsPath$ = adoRecordSet\GetStringProperty("Fields('adsPath')\Value")
              
              PrintN("Darrick is: ")
              PrintN(#TAB$ + cn$)
              PrintN(#TAB$ + dn$)
              PrintN(#TAB$ + adsPath$)

              adoRecordSet\Invoke("MoveNext")
            ForEver
            adoRecordSet\Invoke("Close")
            adoRecordSet\Release()
          Else
            PrintN("Couldn't create the recordset object!")
          EndIf                
        Else
          PrintN("There was a problem adding the records!")
        EndIf                
      Else
        PrintN("Couldn't create open the connection!")
      EndIf        
      adoConnection\Invoke("Close")
      adoConnection\Release()
    Else
      MessageRequester("COMate - ADO demo", "Couldn't create a connection object!")
    EndIf
Has anyone done this successfully that could see what's not working?
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Re: COMatePlus and Active Directory

Post by SFSxOI »

is this a coding question or are you trying to tell us that your announcing your creation?
The advantage of a 64 bit operating system over a 32 bit operating system comes down to only being twice the headache.
Amundo
Enthusiast
Enthusiast
Posts: 200
Joined: Thu Feb 16, 2006 1:41 am
Location: New Zealand

Re: COMatePlus and Active Directory

Post by Amundo »

Should be "Coding Questions"
Win10, PB6.x, okayish CPU, onboard video card, fuzzy monitor (or is that my eyesight?)
"When the facts change, I change my mind" - John Maynard Keynes
Amundo
Enthusiast
Enthusiast
Posts: 200
Joined: Thu Feb 16, 2006 1:41 am
Location: New Zealand

Re: COMatePlus and Active Directory

Post by Amundo »

blackborg: I think there is an error in your SQL query, when I used "<LDAP://dc=myDomainName,dc=co,dc=nz>;;cn;subtree" and it returned results.
Win10, PB6.x, okayish CPU, onboard video card, fuzzy monitor (or is that my eyesight?)
"When the facts change, I change my mind" - John Maynard Keynes
Post Reply