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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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

 



soft_king
Novice

Feb 11, 2009, 10:28 AM

Post #1 of 3 (3844 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.

Code
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)


FishMonger
Veteran / Moderator

Feb 11, 2009, 10:43 AM

Post #2 of 3 (3840 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.


soft_king
Novice

Feb 17, 2009, 7:01 AM

Post #3 of 3 (3787 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.


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("userPrincipalName",$sAMAccountName."$domain");
$objUser->Put("givenName", $finame);
$objUser->Put("sn", $laname);
$objUser->Put("displayName", $finame." ".$laname);
$objUser->Put("description","description");
$objUser->SetInfo;
$objUser->SetPassword("Password");
$objUser->{AccountDisabled} = FALSE;
$objUser->SetInfo;

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


$objUser->Put("profilePath", $profile . $sAMAccountName);
$objUser->Put("homeDirectory", $homedir . $sAMAccountName);
$objUser->Put("homeDrive", "z:");
$objUser->SetInfo;
[\code]

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