I find that manipulating the bitfield constants exported by many modules including Win32::Lanman to be APITA. It would be much easier if you could iterate through the bit fields. There is mention in the docs of the same constants being exported as a hash %NET_STATUS_DESCRIPTION, but it also says that it is a work in progress and I couldn't get it to work.

A while ago, I came up with this method of iterating the constants I want from a module, provided they can be selected with a regex pattern.

#! perl -slw use strict; use Win32::Lanman; Win32::Lanman::NetUserEnum( 'HIAWATHA', 0, \my @users ) or die $^E; for my $user ( @users) { print $user->{name}; printf "%35s : %d\n", $_, !!( $user->{flags} & do{ no strict 'refs'; &$_ } ) for grep{ /^UF_/ } keys %Win32::Lanman::; } __END__ Fred1 UF_SETTABLE_BITS : 1 UF_SMARTCARD_REQUIRED : 0 UF_DONT_REQUIRE_PREAUTH : 0 UF_NORMAL_ACCOUNT : 1 UF_LOCKOUT : 0 UF_HOMEDIR_REQUIRED : 0 UF_SERVER_TRUST_ACCOUNT : 0 UF_PASSWD_CANT_CHANGE : 1 UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED : 0 UF_NOT_DELEGATED : 0 UF_USE_DES_KEY_ONLY : 0 UF_WORKSTATION_TRUST_ACCOUNT : 0 UF_PASSWD_NOTREQD : 0 UF_MACHINE_ACCOUNT_MASK : 0 UF_TRUSTED_FOR_DELEGATION : 0 UF_ACCOUNT_TYPE_MASK : 1 UF_INTERDOMAIN_TRUST_ACCOUNT : 0 UF_MNS_LOGON_ACCOUNT : 0 UF_TEMP_DUPLICATE_ACCOUNT : 0 UF_ACCOUNTDISABLE : 1 UF_SCRIPT : 1 UF_DONT_EXPIRE_PASSWD : 1

The value you posted below, 66049, translates to

UF_SETTABLE_BITS : 1 UF_SMARTCARD_REQUIRED : 0 UF_DONT_REQUIRE_PREAUTH : 0 UF_NORMAL_ACCOUNT : 1 UF_LOCKOUT : 0 UF_HOMEDIR_REQUIRED : 0 UF_SERVER_TRUST_ACCOUNT : 0 UF_PASSWD_CANT_CHANGE : 0 UF_ENCRYPTED_TEXT_PASSWORD_ALLOWED : 0 UF_NOT_DELEGATED : 0 UF_USE_DES_KEY_ONLY : 0 UF_WORKSTATION_TRUST_ACCOUNT : 0 UF_PASSWD_NOTREQD : 0 UF_MACHINE_ACCOUNT_MASK : 0 UF_TRUSTED_FOR_DELEGATION : 0 UF_ACCOUNT_TYPE_MASK : 1 UF_INTERDOMAIN_TRUST_ACCOUNT : 0 UF_MNS_LOGON_ACCOUNT : 0 UF_TEMP_DUPLICATE_ACCOUNT : 0 UF_ACCOUNTDISABLE : 0 UF_SCRIPT : 1 UF_DONT_EXPIRE_PASSWD : 1

As you can see, the UF_ACCOUNT_DISABLED flag is not set in that mask. Maybe you will find that useful.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
Hooray!
Wanted!


In reply to Re: Win32::Lanman::NetUserEnum ... FLAGS by BrowserUk
in thread Win32::Lanman::NetUserEnum ... FLAGS by Anonymous Monk

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.