CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Win32 Programming Help:
syntax woes



Feb 11, 2009, 10:28 AM

Post #1 of 3 (7202 views)
syntax woes Can't Post

I tried running this script that I got online and I keep getting this syntax error and I don't know why. Can someone help me? I'm trying to retrieve over 1000 records from Active Directory. The code is below.

use Win32::OLE 'in'; 
$colUsers = Win32::OLE->GetObject("LDAP://cn=users,dc=rallencorp,dc=com")
foreach $objUser (in $colUsers) {
print $objUser->Name,"\n";

I keep getting this message in cmd
syntax error at line 3, near "$objUser ( "

(This post was edited by soft_king on Feb 11, 2009, 10:31 AM)

Veteran / Moderator

Feb 11, 2009, 10:43 AM

Post #2 of 3 (7198 views)
Re: [soft_king] syntax woes [In reply to] Can't Post

You're missing the semi-colon on the line above it, so perl thinks the foreach line is a continuation of that line.


Feb 17, 2009, 7:01 AM

Post #3 of 3 (7145 views)
Re: [FishMonger] syntax woes [In reply to] Can't Post

Thanks guys....
Another thing. I'm trying to create a user with perl and it I keep getting and error:

An invalid directory pathname was passed
Win32::OLE(0.1709) error 0x80005000 in METHOD/PROPERTYGET "Create". This is the code.

my $fullname = $finame." ".$laname; 

my $objParent = Win32::OLE->GetObject("LDAP://OU=MyOU,dc=Mydomain,dc=ext");
my $objUser = $objParent->Create("user","cn=".$fullname);
$objUser->Put("sAMAccountName", $sAMAccountName);
$objUser->Put("givenName", $finame);
$objUser->Put("sn", $laname);
$objUser->Put("displayName", $finame." ".$laname);
$objUser->{AccountDisabled} = FALSE;

my $homedir = "\\\\server\\ext\\";
#my $homedrive = "";
my $profile = "\\\\server\\ext\\";

$objUser->Put("profilePath", $profile . $sAMAccountName);
$objUser->Put("homeDirectory", $homedir . $sAMAccountName);
$objUser->Put("homeDrive", "z:");

My hunch is that something is wrong with the create line "my $objUser = $objParent->Create("user","cn=".$fullname);" but i can't figure out what it is. Can you help me?

(This post was edited by soft_king on Feb 17, 2009, 7:19 AM)


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives