Deleting users from an OU - Jerem

30-May-07 02:13:02
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
reply
 
 

Deleting users from an OU - Richard Mueller [MVP]

30-May-07 02:38:08
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
--
reply
 

Deleting users from an OU - Jeremy Schubert

30-May-07 07:46:46
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...
reply
 

Deleting users from an OU - Richard Mueller [MVP]

30-May-07 08:08:40
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.
reply
 

Deleting users from an OU - Jeremy Schubert

30-May-07 08:53:19
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
reply
 
Replace Lines between 2 lines
promotion
Silverlight    WPF    WCF    WWF    LINQ   
JavaScript    AJAX    ASP.NET    XAML   
C#    VB.NET    VB 6.0    GDI+    IIS    XML   
.NET Generics    Anonymous Methods    Delegate   
Visual Studio .NET    Expression Blend    Virus   
Windows Vista    Windows XP    Windows Update   
Windows 2003 Server    Windows 2008 Server   
SQL Server    Microsoft Excel    Microsoft Word   
SharePoint    BizTalk    Virtual Earth   
.NET Compact Framework    Web Service   

"Everything" RSS / ATOM Feed Parser
How to send and receive messages through message queuing in .Net
How to Read text file as database
SQL Server 2005 Paging Performance Tip
Display code of web page.
Fully Scalable Excel File Importer class for .net using Microsoft Jet driver
Generic Chart Color Manager class that can be used for any charts
Helper class to style the infragistics wingrid
Using Reflection to detemine as Assembly Info in and out.
Helper class to play with Window (Owners and position)
Resolving displayname from the culture using the XmlLanguage and LanguageSpecificStringDictionary class