C++/VB - Deleting users from an OU

Asked By Jerem
30-May-07 02:13 PM
When I run the following script, I get an error message: Line 2, Char 19,
Exprected end of statement.
Can anyone help me out please?

Set objOU =
GetObject("LDAP://ou=047UDiploma,ou=047USchool,ou=sectionU06,ou=User
Accounts,dc=student,dc=cssd,dc=ab,dc=ca")
objOU.Delete user cn=047-c110-01
objOU.Delete user cn=047-c110-02
objOU.Delete user cn=047-c110-03
objOU.Delete user cn=047-c110-04
objOU.Delete user cn=047-c110-05
objOU.Delete user cn=047-c110-06
objOU.Delete user cn=047-c110-07
objOU.Delete user cn=047-c110-08
objOU.Delete user cn=047-c110-09
objOU.Delete user cn=047-c110-10
objOU.Delete user cn=047-c110-11
ObjOU
(1)
StrUserCN
(1)
Excel
(1)
StrClass
(1)
ObjCell
(1)
IntRow
(1)
OU
(1)
ProfilePath
(1)
  Richard Mueller [MVP] replied...
30-May-07 02:38 PM
The parameters of the Delete method need to be in quotes, separated by a
comma. The syntax should be:

objOU.Delete "user", "cn=047-c110-01"

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--
  Jeremy Schubert replied...
30-May-07 07:46 PM
Thanks Richard.  I tried your suggestion before posting but it didn't work.
But now it is.  It's a long, sordid story...
I used Excel to masage together my user names and the paramters.  Then I
realized I needed double quotation marks around the parameters.  I was able
to use the replace function in Notepad to add most of the double quotes, but
I couldn't figure out how to 'say' add double quotes to the end of each line
(in Notepad).  Word let me use ^p in the replace function so I could replace
^p with ^p".  But then when I ran the script, the computer wouldn't
recongnize the double quotes produced by Word.  So I finally figured out to
use the Word replace function to add ZZ to the end of each line.  Then, in
Notepad, I was able to replace the ZZ with double quotes created by Notepad
and all worked well.  Then I cursed and said to myself, "The accounts
already existed.  Why didn't I just export them to a txt file instead of an
Excel file and massaging data from there!"  Next time...
  Richard Mueller [MVP] replied...
30-May-07 08:08 PM
I'm not sure what your code looks like, but the Delete method parameters can
be variables with string values assigned. For example, I would expect code
similar to the following to work:

strClass = "user"
strUserCN = objCell(intRow, intCol).Value
objOU.Delete strClass, "cn=" & strUserCN

and, if objCell(intRow, intCol).Value is equal to "cn=047-c110-01", then you
could use:

objOU.Delete strClass, strUserCN

The reason the first version did not work is that without the quotes, the
interpreter decided that user and cn=047-c110-01 were both variable names
(with blank values). The important thing is that you got the program to
work.
  Jeremy Schubert replied...
30-May-07 08:53 PM
Thank you again Richard.  Going on what you have here, if I wanted to add a
profile path to all users, I could do something like

strUserCN=objCell(intRow,2).Value
objUser.Put "profilePath", \\server\profile.man$

and just have it loop til it comes to an empty cell?  (assuming I have the
values for CN in column 2)

Jeremy
Create New Account
help
create Excel spreadsheet without loading Excel C++ / VB Greetings, I have a script which uses CreateObject("Excel.Application") to create a spreadsheet. This works fine on my machine since I have Excel loaded. I plan to move the script to a server & would like to avoid loading Excel on that machine. Is it not possible to just put certain files (DLLs?) on the server without performing a full install? Thanks VBScript Discussions Excel (1) VBScripts (1) Database (1) DLLs (1) CreateObject (1) Salvador (1) Manaois (1) Badz (1 it is installed, a process which registers its application object. / Al You can install the Excel viewer to open, view, and print Excel workbooks, even if you don't have Excel installed. You can also copy data from
Scripting an Excel add-in C++ / VB Hi, I have a vbscript that gets and controls Excel via Excel's built-in objects. But now I want to use objects and functions from a plugin that's currently loaded in Excel. I tried the following: Set xl = CreateObject Excel.Application") set wbAddin = xl.Workbooks("AddinName.xla") 'successfull! set ObjectFromWithinAddin = wbAddin.PublicObject 'Error! dummy = wbAddin.PublicFunction() 'Error! = = > How can this be done? Thanks. Robert VBScript Discussions Excel (1) VBA (1) ObjectFromWithinAddin (1) WbAddin.PublicObject (1) CreateObject (1) WbAddin (1) Vbscript (1) Plugin 1) Have you tried doing this from within Excel (using VBA) ? If it does not work there then it most likely will not work doesn't work that way. And I realized that the problem is mostly related to Excel. In a VBA project, You only have to set a link to the other VBA
application / vnd.ms-excel and macros C++ / VB Is there anyway to build an Excel macro into a WEB page with contenttype equaling application / vnd.ms-excel? VBScript Discussions Excel 2003 (1) Office (1) Excel (1) VBA (1) ExcelWorkbook (1) Contenttype (1) Aboutwhat (1) Unorthox (1) Rick, it might be helpful to explain a little more about what you want to do. Sending excel macro code to somebody's client system sounds like it could be a security violation at the OWC Spreadsheet component. (OWC = Office Web Components). The OWC Spreadsheet looks enough like excel to fool most people (at least xl2k and xl2003 users). cheers, jw _ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ _ You got answers will be applicable to the questions) I have an asp page that opens into Excel. The page itself needs split into several worksheets. I have a macro that will split
How to check whether MS Excel is installed or not in the System C++ / VB Hi All, I hav an MFC apllication, which is used to store some report data to an Excel file (using Excel automation process). Before i store the data to excel file, i need to check whether MS Excel is installed in the system or not. if excel is not installed then i have to store the data to text file. So how do i check whether excel is installed or not using MFC programming? - - Thanks Ash Jings VC MFC Discussions Windows Installer 1) Microsoft Excel (1) Word (1) RegOpenKeyEx (1) ProgIDExists (1) Word.Basic (1) RegCloseKey (1) SzProgID (1) Since