Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Thanks for the help, syphilis.

In the typical win32 way, things don't seem to be behaving as specified. Appending the dollar sign gives an error, and using the computer name seems to return a domain SID.

I'm working on a system that's not a member of a domain, with username "shop_user" and "system name" is "SHOP_02". FWIW, I'm testing on Windows XP systems with ActiveState Perl 5.8.8.

use strict; use warnings; use Win32::Security::SID; my @SIDTYPE = qw( ERROR SidTypeUser SidTypeGroup SidTypeDomain SidTypeAlias SidTypeWellKnownGroup SidTypeDeletedAccount SidTypeInvalid SidTypeUnknown SidTypeComputer SidTypeLabel ); my ( $system, $account ); $account = Win32::LoginName; $system = Win32::NodeName; GetSID( $system, "$system\\$account"); GetSID( $system, $account); GetSID( $system, $system); GetSID( $system, "$system\\"); GetSID( $system, "\\$system"); GetSID( $system, "SYSTEM\\$system"); GetSID( $system, "\$$system"); GetSID( $system, "$system\$"); GetSID( $system, "$system\\\$"); sub GetSID { my $system = shift; my $account = shift; my $domain = shift; no warnings 'uninitialized'; my ( $sid, $sidtype ); Win32::LookupAccountName( $system, $account, $domain, $sid, $sidty +pe ); my $sidstring = Win32::Security::SID::ConvertSidToStringSid( $sid +); print "\n", "$system - $account - $domain\n", "SID: $sidstring\n", "SIDTYPE: $SIDTYPE[$sidtype]\n"; ; }

Here are the results:

SHOP_02 - SHOP_02\shop_user - SHOP_02 SID: S-1-5-21-1957994488-963894560-725345543-1004 SIDTYPE: SidTypeUser SHOP_02 - shop_user - SHOP_02 SID: S-1-5-21-1957994488-963894560-725345543-1004 SIDTYPE: SidTypeUser SHOP_02 - SHOP_02 - SHOP_02 SID: S-1-5-21-1957994488-963894560-725345543 SIDTYPE: SidTypeDomain SHOP_02 - SHOP_02\ - SID: SIDTYPE: ERROR SHOP_02 - \SHOP_02 - SHOP_02 SID: S-1-5-21-1957994488-963894560-725345543 SIDTYPE: SidTypeDomain SHOP_02 - SYSTEM\SHOP_02 - SID: SIDTYPE: ERROR SHOP_02 - $SHOP_02 - SID: SIDTYPE: ERROR SHOP_02 - SHOP_02$ - SID: SIDTYPE: ERROR SHOP_02 - SHOP_02\$ - SID: SIDTYPE: ERROR


TGI says moo


In reply to Re^2: Win32: Getting the Machine SID by TGI
in thread Win32: Getting the Machine SID by TGI

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-20 04:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found