RE: Help with LookupAccountSID (again)
Sorry, I just found this code snippet I had tucked away. Having it is one thing, knowing where you put it is another! :) use Win32; use Win32::NetAdmin; use strict; my @all; Win32::NetAdmin::GetServers(undef, MYDOMAIN, SV_TYPE_ALL, \@all); foreach my $computer(sort @all){ my ($name,$domain,$sid,$stype); Win32::LookupAccountName($computer, $computer, $domain, $sid, $stype); my($Revision, $SubAuthorityCount,@IdentifierAuthorities) = unpack(CCnnn, $sid); my($temp, $temp2, @SubAuthorities) = unpack(VVV$SubAuthorityCount,$sid); print \n$computer,S-$Revision-$IdentifierAuthorities[2]-.join(-,@SubAuthor ities); } -Original Message- From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Barry Brevik Sent: Wednesday, July 18, 2012 2:45 PM To: Cordoni, Ray; perl Win32-users Subject: RE: Help with LookupAccountSID (again) Ay Caramba!! I thank you for the post, but my skills are too low to reverse that monstrosity! Barry Brevik -Original Message- From: Cordoni, Ray [mailto:rcord...@richmond.ca] Sent: Wednesday, July 18, 2012 11:38 AM To: Barry Brevik; perl Win32-users Subject: RE: Help with LookupAccountSID (again) Not sure if this helps, but long ago I had to convert a binary SID to a string - exactly the opposite of what you want! Here is the perl routine: # Translate binary objectsid to string value # sub SidToString { (my $sid) = @_; my $sid_str_hex = S; my $loop; return undef unless unpack(C, substr($sid, 0, 1)) == 1; return undef unless length($sid) == 8 + 4 * unpack(C, substr($sid, 1, 1)); for $loop (0 .. unpack(C, substr($sid, 1, 1)) - 1) { $sid_str_hex .= - . substr(unpack(H*, substr($sid, 4 * $loop + 8, 4)), 6, 2) . substr(unpack(H*, substr($sid, 4 * $loop + 8, 4)), 4, 2) . substr(unpack(H*, substr($sid, 4 * $loop + 8, 4)), 2, 2) . substr(unpack(H*, substr($sid, 4 * $loop + 8, 4)), 0, 2); } $sid_str_hex =~ s/-0*/-/g; return $sid_str_hex; } - Raymond Cordoni Manager of Web, GIS and Database City of Richmond - Information Technology 604-276-4003 rcord...@richmond.ca -Original Message- From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Barry Brevik Sent: Wednesday, 18 July 2012 11:30 To: perl Win32-users Subject: Help with LookupAccountSID (again) Previously I had asked for help with Win32::LookupAccountSID(). Specifically, the call requires that the SID be in a binary format. One helpful user pointed me to this: http://code.activestate.com/lists/perl-win32-users/26301/ All of that works, except the article's author is first getting the binary SID from the Win32::LookupAccountName() call, which is a chicken and egg thing. I need to know how to convert a SID like this: '{S-1-5-21-1406052347-744958519-1677701-1424}' ...into its equivalent binary form for use in the Win32::LookupAccountSID() call. Does anyone out there know how to do this? TIA, Barry Brevik ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: help with Win32
To the best of my knowledge (I'd love to be wrong here), this information does not exist. Best case scenario, you'd have to turn on some audit flags and from there parse event log information. Also, this would only work from a point in time. We chose to leverage a logon script with a sub routine addition to record a login to a database. What flexibility/rights do you have with regards to the workstations? -Original Message- From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Barry Brevik Sent: Monday, June 04, 2012 2:20 PM To: perl Win32-users Subject: help with Win32 I have both of the Roth books, but I've come up empty. I have a need to determine which client machine a given user (or all users) has logged into the domain from. I'm willing to back into it by starting with all client machines. I'm willing to process all of the machines and users in the domain if necessary. In fact, I'm willing to jump through a fair number of hoops to collect this information. Does anyone out there know how to do this, or at least have an idea as to how to do this? Thanks in advance, Barry Brevik ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Setting file server time
I've used Win32-OLE to start/execute processes on remote computers. In this scenario you could use Win32-OLE to call time -Original Message- From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Barry Brevik Sent: Monday, September 26, 2011 8:24 PM To: Tobias Hoellrich; Howard Tanner; perl-win32-users@listserv.ActiveState.com Subject: RE: Setting file server time Yes NTP. Well, if the guy had it setup right it would work, but no. So I had to create an internet time server bot (with a little help) which sets the local machine time. I was hoping to employ a Win32-only solution to then set the domain controller rather than spawn one of the pstools (I am familiar with them). -Original Message- From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Tobias Hoellrich Sent: Monday, September 26, 2011 4:44 PM To: Howard Tanner; perl-win32-users@listserv.ActiveState.com Subject: RE: Setting file server time Since the advent of NTP on the Windows platforms I don't remember the last time there was a need to set the time manually :-) Thanks- T -Original Message- From: Howard Tanner [mailto:tan...@optonline.net] Sent: Monday, September 26, 2011 5:26 PM To: Tobias Hoellrich; 'Barry Brevik'; perl-win32-users@listserv.ActiveState.com Subject: RE: Setting file server time NET TIME was my first thought too, but it only allows you to set your time to that of another machine. ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: WMI remote querying
Aside from the userid and possibly the password, your code looks good. I copied the code and ran it with no issues. By default, the admin account is named 'administrator' not 'admin' Output was: DBI::db=HASH(0x1b9fd3c) ServicePackMajorVersion is 3 ServicePackMinorVersion is 0 From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of David Evans Sent: Tuesday, March 24, 2009 8:21 AM To: perl-win32-users@listserv.ActiveState.com Subject: WMI remote querying Hi wonderful people I hope one of you can help me. I need to access WMI on a remote Win XP desktops and I am getting permission errors when using the local admin account on the remote box. Any ideas? CODE: use DBI; my $machine = 'server'; my $dbh = DBI-connect('dbi:WMI:'.$machine,'admin','admin'); print $dbh\n; my $sth = $dbh-prepare('SELECT * FROM Win32_OperatingSystem'); $sth-execute; while (my @row = $sth-fetchrow) { my $printer = $row[0]; printf ServicePackMajorVersion is %s\n, $printer-{ServicePackMajorVersion}, $machine; printf ServicePackMinorVersion is %s\n, $printer-{ServicePackMinorVersion}, $machine; }; ERROR: C:\Scripting\toyswmi.pl Win32::OLE(0.1707) error 0x80070005: Access is denied after character 0 in winmgmts:\\server\root\cimV2 at C:/Perl/site/lib/DBD/ WMI.pm line 95 Any help greatly appreciated. Thanks Dave PS My system is... Host: WinXP SP2 Perl: 5.8.8 Build 822 DBD::WMI 0.06 DBI 1.607 ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Questions on porting Perl from Unix to Windows
Readdir and file::copy? From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Gary Yang Sent: Thursday, January 24, 2008 2:16 PM To: perl-win32-users@listserv.ActiveState.com Subject: Questions on porting Perl from Unix to Windows Hi All, I need to port my Perl script from Unix to Windows. Can someone tell me how to figure out which platform I am on? i.e. I need to know which Perl command can help me determin the platform. Once I know the platform, I'll code my script as the example bellow. But, how to figure out I am on Windows or Unix? if ($usingUNIX) { $directory = `ls`; #UNIX version. $copyCommand = `cp`; #UNIX version. } else { $directory = `dir`; #Win32 version. $copyCommand = `COPY`; #Win32 version. } Second question: The UNIX #!/usr/bin/perl notation does not work with Perl scripts on Windows. How should I code if it is Unix I place #!/usr/bin/perl at the very first line of the script? But, I do not place it at the first line of code if it is not Unix? How should I do it? Your answers are greatly appreciated. Thanks, Gary Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://us.rd.yahoo.com/evt=51734/*http:/tools.search.yahoo.com/newsearc h/category.php?category=shopping ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: reading the Network Interface Card(NIC) name
Google: scriptomatic Microsoft provides this tool to demonstrate how to utilize WMI. One of the features is to output code in various languages, PERL being one. From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Steve Howard (PFE) Sent: Monday, August 27, 2007 11:53 AM To: Ankit Mehrotra; Foo JH Cc: perl-win32-users@listserv.ActiveState.com; [EMAIL PROTECTED] Subject: RE: reading the Network Interface Card(NIC) name You can access WMI via Perl pretty much the same way you would any other automation object. I haven't used it to enumerate the NICs the way you want to do, but a quick and dirty example of using WMI in Perl is one I wrote to enumerate drives. You can probably use the windows scripting help to find the objects for the NICs. An example of using Perl with WMI: #!perl use Win32; use Win32::OLE qw( in ); *error = *Win32::OLE::LastError; my $wmi = Win32::OLE-GetObject(Winmgmts:); die error() if error(); our $drives = $wmi-ExecQuery(Select * from Win32_LogicalDisk); die error() if error(); foreach my $drive (in( $drives )) { print drive name: $drive-{Name}\n; print filesystem: $drive-{FileSystem}\n; print Drive size: $drive-{Size}\n; print Drive freespace: $drive-{FreeSpace}\n; print Drive type: $drive-{DriveType}\n; print \n\n; } From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ankit Mehrotra Sent: Monday, August 27, 2007 2:48 AM To: Foo JH Cc: perl-win32-users@listserv.ActiveState.com; [EMAIL PROTECTED] Subject: Re: reading the Network Interface Card(NIC) name I am not very well versed in wmi. Is there some other means of doing it preferably using perl !! Ankit Foo JH [EMAIL PROTECTED] 08/27/2007 12:37 PM To Ankit Mehrotra [EMAIL PROTECTED] cc perl-win32-users@listserv.ActiveState.com, [EMAIL PROTECTED] Subject Re: reading the Network Interface Card(NIC) name If you're doing this via Windows, you can go via WMI. Google: wmi win32_networkadapter Ankit Mehrotra wrote: Hi all, I want to read the names of the NIC's of a blade server. Is there any ready made package through which I can read them ? Thanks Ankit =-=-= Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ForwardSourceID:NT00013B6E =-=-= Notice: The information contained in this e-mail message and/or attachments to it may contain confidential or privileged information. If you are not the intended recipient, any dissemination, use, review, distribution, printing or copying of the information contained in this e-mail message and/or attachments to it are strictly prohibited. If you have received this communication in error, please notify us by reply e-mail or telephone and immediately and permanently delete the message and any attachments. Thank you ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Identify if a program is running on a Laptop or Desktop syste m
Title: RE: Identify if a program is running on a Laptop or Desktop system ...or check for battc.sys -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of [EMAIL PROTECTED] Sent: Monday, September 11, 2006 3:03 PM To: perl-win32-users@listserv.ActiveState.com Subject: Re: Identify if a program is running on a Laptop or Desktop system Download Scriptomatic from Microsoft. It has a good WMI browswer in it. That's what I'ld do to look for anything. At 05:33 PM 9/11/2006 +0200, StoneBeat wrote: Hi, i want to code a program that if it is running on a laptop system do something but if the host is not a laptop, do another. Im thinking in registry keys, WMI querys ... but really I dont know where search to fingerprint the host. -- REMEMBER THE WORLD TRADE CENTER ---= WTC 911 =-- ...ne cede malis 0100 ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs