LDAP Search using ADSI and VBScript -> ADODB Error

LDAP Search using ADSI and VBScript -> ADODB Error

Post by Jack Laure » Wed, 19 Feb 2003 20:34:12



Hello everybody,

I've got the following Problem:
I wrote a User Loginscript with vbs. In this Script I use
an ADODB Connection Object so I can search the AD for the
Users own User Object.

Sourcecode:

Set Connection = CreateObject("ADODB.Connection")
Connection.Provider = "ADsDSOObject"
Connection.Open "Active Directory Provider"
Set rs = CreateObject("ADODB.Recordset")

When I run this script on some Clients I get error number
800a0007 out of memory in the las line (Set
rs=CreateObject("ADODB.Recordset"). On other Clients the
script runs without Problems.....

All Information I get in Technet and the Internet are
concerned with ASP Programming.

Has anyone seen this problem before? And more important..
how can I solve this problem?

Thanx in advance..
Jack

 
 
 

LDAP Search using ADSI and VBScript -> ADODB Error

Post by Richard Muelle » Thu, 20 Feb 2003 02:17:58



>Hello everybody,

>I've got the following Problem:
>I wrote a User Loginscript with vbs. In this Script I use
>an ADODB Connection Object so I can search the AD for the
>Users own User Object.

>Sourcecode:

>Set Connection = CreateObject("ADODB.Connection")
>Connection.Provider = "ADsDSOObject"
>Connection.Open "Active Directory Provider"
>Set rs = CreateObject("ADODB.Recordset")

>When I run this script on some Clients I get error number
>800a0007 out of memory in the las line (Set
>rs=CreateObject("ADODB.Recordset"). On other Clients the
>script runs without Problems.....

>All Information I get in Technet and the Internet are
>concerned with ASP Programming.

>Has anyone seen this problem before? And more important..
>how can I solve this problem?

>Thanx in advance..
>Jack

Hi,

The code you posted did not raise an error on any of my
machines, even with MDAC 2.1. Generally, ADO requires MDAC
2.5 or above. Check the versions of msdadc.dll and
oledb32.dll. Both should be at least 2.50.

Also, you method is not efficient on very large networks.
If you use ADO, I recommend using the GC as the base for
the search. I assume you retrieve the user NT name
(sAMAccountName) from the WshNetwork object and use Ad

 
 
 

LDAP Search using ADSI and VBScript -> ADODB Error

Post by Richard Muelle » Thu, 20 Feb 2003 02:29:33


Sorry, my post got sent before I was done. Continuing...

I assume you get the NT name from WshNetwork and need to
bind to the user object with the LDAP provider. A more
direct approach would be to use the NameTranslate object
to convert the NT name to the Distinguished Name. It can
also be used to convert the DNS domain name retrieved from
the RootDSE object to the NetBIOS domain name required for
NameTranslate to convert the NT name. The RootDSE object
is provided by AD. The NameTranslate object is available
on W2k and above, and any other client with DSClient
installed. I use the following:

Option Explicit

Dim oRoot, oTrans, sNetBIOSDomain, oNet, sNTName, sAdsPath
Dim oGroupList, sGroup, oUser, sDNSDomain
Dim sComputer, oComputer, sComputerGroup

Set oNet = CreateObject("Wscript.Network")

' Loop required for Win9x clients during logon.
sNTName = ""
On Error Resume Next
Err.Clear
Do While sNTName = ""
  sNTName = oNet.UserName
  Err.Clear
  If Wscript.Version > 5 Then
    Wscript.Sleep 100
  End If
Loop
On Error GoTo 0

' Determine DNS domain name from RootDSE object.
Set oRoot = GetObject("LDAP://RootDSE")
sDNSDomain = oRoot.Get("DefaultNamingContext")

' Use the NameTranslate object to find the NetBIOS
' domain name from the DNS domain name.
Set oTrans = CreateObject("NameTranslate")
oTrans.Init 3, sDNSDomain
oTrans.Set 1, sDNSDomain
sNetBIOSDomain = oTrans.Get(3)

' Use the NameTranslate object to convert the NT user
' name to the Distinguished Name.
oTrans.Init 1, Left(sNetBIOSDomain, _
  Len(sNetBIOSDomain) - 1)
oTrans.Set 3, sNetBIOSDomain & sNTName
sAdsPath = oTrans.Get(1)

' Bind to the user object in AD with the LDAP provider.
Set oUser = GetObject("LDAP://" & sAdsPath)

Richard

>-----Original Message-----

>>Hello everybody,

>>I've got the following Problem:
>>I wrote a User Loginscript with vbs. In this Script I
use
>>an ADODB Connection Object so I can search the AD for
the
>>Users own User Object.

>>Sourcecode:

>>Set Connection = CreateObject("ADODB.Connection")
>>Connection.Provider = "ADsDSOObject"
>>Connection.Open "Active Directory Provider"
>>Set rs = CreateObject("ADODB.Recordset")

>>When I run this script on some Clients I get error
number
>>800a0007 out of memory in the las line (Set
>>rs=CreateObject("ADODB.Recordset"). On other Clients the
>>script runs without Problems.....

>>All Information I get in Technet and the Internet are
>>concerned with ASP Programming.

>>Has anyone seen this problem before? And more
important..
>>how can I solve this problem?

>>Thanx in advance..
>>Jack

>Hi,

>The code you posted did not raise an error on any of my
>machines, even with MDAC 2.1. Generally, ADO requires
MDAC
>2.5 or above. Check the versions of msdadc.dll and
>oledb32.dll. Both should be at least 2.50.

>Also, you method is not efficient on very large networks.
>If you use ADO, I recommend using the GC as the base for
>the search. I assume you retrieve the user NT name
>(sAMAccountName) from the WshNetwork object and use Ad
>.

 
 
 

LDAP Search using ADSI and VBScript -> ADODB Error

Post by Jack Laure » Fri, 21 Feb 2003 00:47:51


Richard,

Thanks very much,

I have incorporated the new code in my script and have
send it to my customer for testing. See what happens.

Concerning the MDAC, I told the customer to try the old
version of the script (the one using ADO) on a W2K sp3
machine. There it did not funktion, even though the
script worked on another client with the same OS and sp.
After installation of MDAC 2.6sp2 the script suddenly
worked. Why oh why? My guess is that some kind of
programm did a bit of interfering with the "old" MDAC
installation, especially the ADO part....

Regards,

Jack

 
 
 

LDAP Search using ADSI and VBScript -> ADODB Error

Post by Richard Muelle » Sat, 22 Feb 2003 03:14:46


Hi,

That's scary. W2k is supposed to prevent other programs
downgrading things like MDAC. All problems I've seen have
been with versions before 2.5, which means older clients
must have DSClient installed for ADO to work. Even the
NameTranslate object is only available on Win9x and NT
clients if DSClient is installed.

Richard

Quote:>-----Original Message-----
>Richard,

>Thanks very much,

>I have incorporated the new code in my script and have
>send it to my customer for testing. See what happens.

>Concerning the MDAC, I told the customer to try the old
>version of the script (the one using ADO) on a W2K sp3
>machine. There it did not funktion, even though the
>script worked on another client with the same OS and sp.
>After installation of MDAC 2.6sp2 the script suddenly
>worked. Why oh why? My guess is that some kind of
>programm did a bit of interfering with the "old" MDAC
>installation, especially the ADO part....

>Regards,

>Jack
>.

 
 
 

LDAP Search using ADSI and VBScript -> ADODB Error

Post by postmaste » Sun, 23 Feb 2003 06:45:05


Hi Richard,

let's make thing even scarier.....

My customer tried the script on a client on which the previous version (the
one with the ADODB object) worked fine. Guess what.. On this client the new
script broke of with the 800a0007 error!
Somehow I feel like this problem is shoving me closer and closer to a mental
breakdown...

Regards,
Jack


Quote:> Hi,

> That's scary. W2k is supposed to prevent other programs
> downgrading things like MDAC. All problems I've seen have
> been with versions before 2.5, which means older clients
> must have DSClient installed for ADO to work. Even the
> NameTranslate object is only available on Win9x and NT
> clients if DSClient is installed.

> Richard
> >-----Original Message-----
> >Richard,

> >Thanks very much,

> >I have incorporated the new code in my script and have
> >send it to my customer for testing. See what happens.

> >Concerning the MDAC, I told the customer to try the old
> >version of the script (the one using ADO) on a W2K sp3
> >machine. There it did not funktion, even though the
> >script worked on another client with the same OS and sp.
> >After installation of MDAC 2.6sp2 the script suddenly
> >worked. Why oh why? My guess is that some kind of
> >programm did a bit of interfering with the "old" MDAC
> >installation, especially the ADO part....

> >Regards,

> >Jack
> >.

 
 
 

1. ADO/ADSI -> LDAP query -> Exchange 5.5 -> Error 80040e37

Hello NG...

I have some Problems getting a LDAP query to work...
I just browsed that NG for some hints but none pointed
me in the right direction...

I want to read all Recipients from an Exchange-Server 5.5
using ADO/ADSI and VB

When i run that code the line "Set rs = con.Execute..." raises an
Error 80040e37 (Table not defined)...
i can't figure out which "table"...

----------------

Dim con As ADODB.Connection
Dim rs As ADODB.Recordset

Set con = New ADODB.Connection
con.Provider = "ADSDSOObject"
con.Open "ADs Provider"

Set rs =
con.Execute("<LDAP://192.168.100.6/o=Testorg/ou=Testou/cn=Recipients>;(objectClass=person);ADsPath,cn,uid;subtree")

While Not rs.EOF
  Debug.Print rs.Fields("ADsPath") & " , " & rs.Fields("cn")
    rs.MoveNext
Wend
con.Close

------------------

Can anyone tell me what's wrong here... would be great...

thanx in advance

Markus Hass

2. A1200 into towercase

3. How to query a non-Windows LDAP server using ADSI and vbscript

4. SEL-HPC WWW HPC Archive

5. How can I search an entire active directory via ADSI using vbscript?

6. windows notebook

7. ASP -> LDAP/ADSI -> AD => Poor Performance

8. Callsman Author

9. Searching Ex55 Directory with ADSI & ADODB

10. search using adodb

11. LDAP -> ADSI -> ADO

12. ADSI LDAP Here is some helpfull VBScript

13. Error accessing ADSI using LDAP