d'oh!  I DID fail to notice.  I guess I have some downloading ahead of me...

-----Original Message-----
From: Fernando Madruga
To: [EMAIL PROTECTED]
Sent: 8/2/02 1:19 AM
Subject: RE: Win32 Perl Books examples (WAS: creating Win2k users with perl)


Well, I've bought that book and Win32 Perl Programming: The Standard
Extensions 2nd Edition (Dave Roth's other book), and in case you failed
to notice, you *can* download all of the examples from both books from
www.roth.net... They are both GREAT books and I'd recommend them both!
Worth every penny! My only complaint is that they don't come available
as PDF files, so I wouldn't have to carry them between home and
office... I'd put them to more use if I had a couple of .PDFs on my
desktop to browse online instead of in paper...

Download Win32:TSE examples here:
http://www.roth.net/redirect/home.asp?source=Extension2;key=extensions2_
scripts

Donwload Win32:TAH examples here:
http://www.roth.net/redirect/home.asp?source=Handbook;key=rc_handbook_ex
amples

Bye,
  Fernando Madruga

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]] On Behalf Of
Timothy Johnson
Sent: quinta-feira, 1 de Agosto de 2002 21:32
To: 'Rick Tatem'; [EMAIL PROTECTED]
Subject: RE: creating Win2k users with perl



Also, if you're going to be working with ADSI, WMI, and Perl, buy Dave
Roth's book, Win32 Perl Scripting: The Administrator's Handbook.  It has
a lot of useful examples.  My only complaint?  I wish the book came with
a CD of the examples.

-----Original Message-----
From: Rick Tatem [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 01, 2002 1:27 PM
To: Rick Tatem; [EMAIL PROTECTED]
Subject: RE: creating Win2k users with perl


All of this assumes that you have permissions to do so. These run under
your current security context.  Otherwise, you just have to authenticate
when getting the initial container object.  Sometimes that requires a
different method (and maybe an extra step or two) but there's plenty of
examples out there, so I'll leave that as an exercise. ;)

Rick

-----Original Message-----
From: Rick Tatem 
Sent: Thursday, August 01, 2002 4:02 PM
To: [EMAIL PROTECTED]
Subject: RE: creating Win2k users with perl


I've always used ADSI via the Win32::OLE (and Win32::OLE::Enum when
needed) module(s).  You can take just about any VBScript example (widely
available... just Google for 'em) and convert to Perl.

In the most general terms:
Open the "container" object using GetObject
Call the 'Create' method of the container, telling it what objectClass
to
  create (user,contact,group,organizationalUnit,etc.)
With the newly created object, Put attributes into place
End w/SetInfo.

Here's an example using the LDAP NameSpace:

        use Win32::OLE;
        my $Name = "First Last";
        my $ID = "filast";
        #
        # "Users is the usual container, but you can select any OU you
might have defined
        #
        my $Container =
Win32::OLE->GetObject("LDAP://CN=Users,DC=domain,DC=com";);
        my $NewUser = $Container->Create("user","CN=" . $Name);
        $NewUser->Put("sAMAccountName",$ID);
        # If you don't Put 512 into userAccountControl, the new account
will be disabled
        $NewUser->Put("userAccountControl",512); 
        #keep ->Putting attribute values as needed...
        #
        $NewUser->SetInfo; #Commit change

Here's one using the WinNT NameSpace (Also works for NT4 domains if ADSI
2.5 is installed) But this example, I'll precede it by the VBScript
version (to see how easy the "translation" is)

VBScript
----------
        ' comment to make the line numbers match :)
        Set oDomain = GetObject("WinNT://Domain")
        Set oUser = oDomain.Create("user", "jdoe")
        oUser.SetInfo
----------

Perl
----------
        use Win32::OLE;
        my $Domain = Win32::OLE->GetObject("WinNT://Domain");
        my $User = $Domain->Create("user, "jdoe");
        $User->SetInfo;
----------

Add some '$' in front of variables, change "." to "->" and you've got a
Perl script!

There's plenty of info available as to what attributes are
required/optional.  I mainly deal with EXISTING accounts, although I do
create new Groups/Distribution Lists alot.  Basically the same tasks.
But These examples are the bare bones.  Once you get into leveraging the
existing VBScript codebase, you can do a lot more (at least _I_ have)
w/the Perl translation.  List (ARRAY) manipulation, string operations,
regexes are all much easier (in my admittedly biased opinion) in perl.
But why re-invent the wheel when you can just hitch a ride with the DLLs
that are already goin' your way?  Just make them more useful.

Rick
---
Rick Tatem
Messaging and Directory Resources
SAS Institute
SAS... The Power To Know (tm)

_______________________________________________
Perl-Win32-Admin mailing list [EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
Perl-Win32-Admin mailing list [EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
Perl-Win32-Admin mailing list [EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to