Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Updating Active Direcory using VBs

Posted on 2001-06-28
8
Medium Priority
?
357 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
  • 4
  • 3
8 Comments
 
LVL 11

Accepted Solution

by:
Otana earned 300 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

927 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