Mayuresh Kshirsagar wrote: > Hope this is the one I should be looking for? > > sub SidToString > { > return undef > unless unpack("C", substr($_[0], 0, 1)) == 1; > > return undef > unless length($_[0]) == 8 + 4 * unpack("C", substr($_[0], 1, > 1)); > > my $sid_str = "S-1-"; > $sid_str .= (unpack("C", substr($_[0], 7, 1)) + (unpack("C", > substr($_[0], 6, 1)) << 8) + > (unpack("C", substr($_[0], 5, 1)) << 16) + > (unpack("C",substr($_[0], 4, 1)) << 24)); > > for $loop (0 .. unpack("C", substr($_[0], 1, 1)) - 1) > { > $sid_str .= "-" . unpack("I", substr($_[0], 4 * $loop + 8, > 4)); > } > return $sid_str; > } > > The input to this will be a binary string right? Or can it be a base64 > value?
This could read a little better: sub SIDToStrSID { # my $tSID = SIDToStrSID ($bSID); my $bsid = shift; # get binary SID my $ver = unpack 'C', substr $bsid, 0, 1; my $wds = unpack 'C', substr $bsid, 1, 1; # return undef unless $ver == 1; # this could change in future return undef unless length $bsid == 8 + 4 * $wds; my $ssid = "S-$ver-" . unpack 'N', substr $bsid, 4, 4; for my $ii (0 .. $wds - 1) { $ssid .= "-" . unpack 'I', substr $bsid, 8 + 4 * $ii, 4; } return $ssid; # string SID } -- ,-/- __ _ _ $Bill Luebkert Mailto:[EMAIL PROTECTED] (_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED] / ) /--< o // // Castle of Medieval Myth & Magic http://www.todbe.com/ -/-' /___/_<_</_</_ http://dbecoll.tripod.com/ (My Perl/Lakers stuff) _______________________________________________ Perl-Win32-Admin mailing list Perl-Win32-Admin@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs