Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: convert VBscript to Perl

by softworkz (Monk)
on Apr 26, 2005 at 17:44 UTC ( #451694=note: print w/ replies, xml ) Need Help??


in reply to Re: convert VBscript to Perl
in thread convert VBscript to Perl

++ for the help!

I figured out how to do this via Perl, below is the code

#!/usr/bin/perl -w use strict; use Win32::OLE; $Win32::OLE::Warn = 3; # Taken from $ADS_USER_FLAG_ENUM my $ADS_UF_NORMAL_ACCOUNT = 512; my $ADS_PROPERTY_APPEND = 3; my $NetId = "zeta28"; my $Name = "Zeta Jones"; my $FName = "Zeta"; my $LName = "Jones"; my $UserDir = "user12"; my $Pass = "S0mePass!"; my $objParent = Win32::OLE->GetObject("LDAP://OU=Domain Users, DC=HEAD +QUARTERS,DC=YOURCOMPANY,DC=com"); my $objUser = $objParent->Create("user", "cn=$Name"); $objUser->Put("sAMAccountName", "$NetId"); $objUser->SetInfo; $objUser->{AccountDisabled} = 0; $objUser->SetInfo; $objUser->SetPassword("$Pass"); $objUser->Put("mail", "$NetId".'@YOURCOMPANY'); $objUser->Put("givenName", "$FName"); $objUser->Put("sn", "$LName"); $objUser->Put("displayName", "$Name"); $objUser->Put("userPrincipalName", "$NetId".'@YOURCOMPANY'); $objUser->SetInfo; # add that user to the user12 global security group my $objGroup = Win32::OLE->GetObject("LDAP://CN=$UserDir, OU=Domain Us +ers, DC=HEADQUARTERS,DC=YOURCOMPANY,DC=com"); $objGroup->PutEx ($ADS_PROPERTY_APPEND, "member", ["cn=$Name,ou=domain + users, dc=HEADQUARTERS, dc=YOURCOMPANY, dc=com"]); $objGroup->SetInfo; # add that user to the general users group $objGroup = Win32::OLE->GetObject("LDAP://CN=General, CN=Users, DC=HEA +DQUARTERS,DC=YOURCOMPANY,DC=com"); $objGroup->PutEx ($ADS_PROPERTY_APPEND, "member", ["cn=$Name,ou=domain + users, dc=HEADQUARTERS, dc=YOURCOMPANY, dc=com"]); $objGroup->SetInfo;


Comment on Re^2: convert VBscript to Perl
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://451694]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (18)
As of 2015-07-29 12:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (263 votes), past polls