Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: convert VBscript to Perl

by softworkz (Monk)
on Apr 26, 2005 at 17:44 UTC ( [id://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;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-26 00:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found