Edited by mirod: added code (and other) tags

I writing a utility to do some parsing/reporting/alerting from the eventlog. I'm trying to deal with the events that are reporting the "Target Account ID:" with a SID not a name.
I'm parsing the $event_handle{STRINGS} and passing LookupAccoutSID the string that contains the SID, but the function fails.
I'm looking for a good example on how this can be done. All my searches seem to keep referring to Win32Faq9 which does not help. It mentions the function, and that's all. No examples.
Here's the code I'm trying to use. It's sloppy, but I'm just tring to get it to work, then I'll worry about efficiency.

@strings = split(/\x00/,$evt_h->{Strings}); foreach $piece (@strings) { print ("string-$piece\n"); } print ("$strings[2]\n"); $mysid=$strings[2]; #tried this to strip off the %,{,} but it didn't help #$mysid =~ s/[\%{}]//g; print ("mysid: $mysid\n"); if Win32::LookupAccountSID($nodename,$strings[2],$account,$domain,$sid +type)) { print ("Account: $account\n"); print (" Domain: $domain\n"); print ("SIDType: $sidtype\n"); } else { print ("LookupAccountSID Error\n"); }

In reply to How to use LookupAccountSID by craigw

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.