Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

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?

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2015-11-25 22:05 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (692 votes), past polls