Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

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;

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://451694]
[Corion]: LanX: Ah, yeah - Frankfurt is in the quake region, but at the very border. I think I've never noticed a quake in Frankfurt myself
[marto]: good morning all
[Corion]: On another topic, in the process of Rubber Duck SoPWing, I wrote a post about the best API for generating HTTP requests (not sending them) and while writing it and fleshing out my sample implementation, I came up with some improvements to my ...
[Corion]: ... existing prototype. Cartesian Products will be proud of that module once it gets out ;)
[Corion]: Hi marto ;)

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2017-01-18 10:13 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (161 votes). Check out past polls.