Solved

Updating Active Direcory using VBs

Posted on 2001-06-28
8
355 Views
Last Modified: 2008-02-01
Hello,

I am trying to update some fields within our Active Directory using VBs.

I am using the following script from miscrosoft as an example:
_____
'Replacing department for all users in OU=sales
Set con = Server.CreateObject("ADODB.Connection")
con.Provider = "ADsDSOObject"
 
Set command = CreateObject("ADODB.Command")
Set command.ActiveConnection = con
 
command.CommandText =
"SELECT AdsPath, cn, FROM '<LDAP://OU=Sales,DC=ArcadiaBay,DC=com>'
 WHERE objectClass = 'user'"
 
Com.Properties("searchscope") = ADS_SCOPE_ONELEVEL
Set rs = Com.Execute
While Not rs.EOF
    Set usr = GetObject(rs.Fields('AdsPath').Value)
    usr.Put "department", "1001"
    usr.SetInfo
    rs.MoveNext
Wend
____

My version is this:
____
Set con = Server.CreateObject("ADODB.Connection")
con.Provider = "ADsDSOObject"

Set command = CreateObject("ADODB.Command")
Set comand.ActiveConnection = con

command.CommandText = "SELECT ADsPath, cn, FROM '<LDAP://CN=v10203,CN=Users,DC=org,DC=local>' WHERE ObjectClass = 'user'"

Com.Properties("searchscope") = ADS_SCOPE_ONELEVEL
Set rs = Com.Execute

While Not rs.EOF
     Set usr = GetObject(rs.fields('AdsPath').Value)
     usr.Put "mail", "aaa@bbb.com"
     usr.Put "manager", "CN=V10316,CN=Users,DC=org,DC=local"
     usr.SetInfo
     rs.MoveNext
Wend
___
I get an error on the followong line:

Set usr = GetObject(rs.fields('AdsPath').Value)

Character 32 saying "Syntax Error 800A03EA"

Can anybody help me with this please?
0
Comment
Question by:ironeye
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 11

Accepted Solution

by:
Otana earned 100 total points
ID: 6234445
Shouldn't the single quotes be double quotes?
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6234471
Either that or it is being strangely case specific as the Name of the field returned is ADsPath not AdsPath. But I would go with the double qoutes first myself.
0
 

Author Comment

by:ironeye
ID: 6234508
Thanks,

I changed the single quotes into double ones and I got a little further.

First I had to change Server.CreateObject into CreateObject, and now I get the following error:

Operation is not allowed on an object referencing a closed or invalid connection. Source: ADODB.Command

Suggestions?
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 11

Expert Comment

by:Otana
ID: 6234523
Set command = CreateObject("ADODB.Command")
Set command.ActiveConnection = con

when you execute these lines, make sure con is already/still opened
0
 

Author Comment

by:ironeye
ID: 6234538
Is that just by saying con.open?
0
 
LVL 11

Expert Comment

by:Otana
ID: 6234548
I think so. You have to make sure though that all your required properties are set, like which database you're connecting on etc.

I believe it's also possible to put these properties in the connectionstring
0
 

Author Comment

by:ironeye
ID: 6234549
I'll go to the testing area and just try! I'll get back.
0
 

Author Comment

by:ironeye
ID: 6251996
it took a while, but i got it going now.

Thanks.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question