Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Changing Dial-In options for Windows 2000

by jds (Acolyte)
on Mar 02, 2003 at 17:50 UTC ( [id://239873]=perlquestion: print w/replies, xml ) Need Help??

jds has asked for the wisdom of the Perl Monks concerning the following question:

Is there a way to use Perl to change the options in the Dial-In tab of Active Directory Users & Computers? I have had excellent success using Win32::AdminMisc for changing many options, but this one eludes me.

Thanks, John

  • Comment on Changing Dial-In options for Windows 2000

Replies are listed 'Best First'.
Re: Changing Dial-In options for Windows 2000
by tachyon (Chancellor) on Mar 03, 2003 at 01:00 UTC

    Do it with VBS. You can automate this by writing a file tmp.vbs executing it and then unlinking it. Here is an example that enables accounts chopped out of one of my AD scripts. You will need to set $TMPVBS, $OU and $DC which are my defined outer scope globals (so shoot me).....

    Do an C:\>ldifde -f dump.txt; type dump.txt to see what $OU and $DC should be if you don't know already.

    sub enable_accounts { my @usernames = @_; open VBS, ">$TMPVBS" or die "Can't write $TMPVBS $!\n"; print VBS "Dim oContainer\n"; for (@usernames) { my @data = split ','; chomp (my $username = pop @data); print VBS qq' Set oContainer=GetObject("LDAP://CN=$username,$OU,$DC") oContainer.AccountDisabled = False oContainer.SetInfo\n'; } print VBS "\nSet oContainer = Nothing"; close VBS; print "Enabling new accounts....."; `$tmpvbs`; print "Done!\n"; unlink $TMPVBS unless $DEBUG; }

    I'll leave it as an exercise for you to find the right property name and what to set it to. Here is a hint I suggest you enumerate the properties and their values.

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

      Well, I never thought of that. Doh!

      This is great for stuff that's hard (or impossible?) with Win32::OLE, as well as quick one-offs.

        Yeah, sometimes you just gotta go with the flow. Bend like a reed in the wind grashopper and use your Perl hammer on a VB nail :-)

        cheers

        tachyon

        s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

      Why would you suggest 1) Creating a new file 2) Writing VB to that file 3) closing it 4) executing it 5) deleting it .. when you can just do this directly in perl?

      my $oContainer = Win32::OLE->GetObject("LDAP://CN=$username,$OU,$DC"); $oContainer->{AccountDisabled} = 0; # FALSE $oContainer->SetInfo();

      There's really nothing you can do in VBS that you can't do in perl... and using an all-perl solution is faster & safer.

        Cool! ++ As for why. Quick and dirty hack to get the job done leveraging VBS? and (limited) Perl knowledge. Your way is much neater. I just did not know about it at the time when we needed it done yesterday ;-) I have only relatively recently started to use Win32::OLE.

        cheers

        tachyon

        s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Re: Changing Dial-In options for Windows 2000
by Jenda (Abbot) on Mar 02, 2003 at 21:02 UTC

    I never needed this so I can't give you much information. Did you look at Win32::Lanman (http://jenda.krynicky.cz/#Win32::Lanman - no it's not mine:)? Or maybe you could use Win32::OLE and WMI.

    Jenda

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (9)
As of 2024-04-19 16:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found