rbaldwin has asked for the wisdom of the Perl Monks concerning the following question:

In a CGI, I would like to be able to authenticate an NT users domain, user id and password for an intranet application I'm developing. I would like the user to enter his info and pass this to a module that would essentially return true or false. I tried #!D:/Perl/bin/perl.exe use Win32::AuthenticateUser; @result = AuthenticateUser("domain", "smith", "abc123"); print @result; But I do not get any results. Does anyone have any suggestions. thanks.

Replies are listed 'Best First'.
Re: NT Authentication
by Adam (Vicar) on Aug 25, 2000 at 23:15 UTC
    Please use <code> tags around your code. This will preserve your formating and provide your readers with some bells and whistles.

    #!D:/Perl/bin/perl.exe use Win32::AuthenticateUser; @result = AuthenticateUser("domain", "smith", "abc123"); print @result;
    I ran AuthenticateUser() in the debugger to see what it does, and found that it returns the empty string '' (false) if the user is not Authentic, and 1 (true) if they are. I would run your script with the -w flag to get warnings. This way you would know that @result was defined when you print it. My suggested test code for you:
    #!D:/Perl/bin/perl.exe -w use strict; #always. use Win32::AuthenticateUser; # My version of Win32::AuthenticateUser did not export the function. my $result = Win32::AuthenticateUser::AuthenticateUser( "domain", "smith", "abc123"); print $result ? 'Authentic User' : 'Unknown User or Password';
Re: NT Authentication
by tye (Sage) on Aug 26, 2000 at 01:45 UTC

    See if the module provides any kind of error reason -- all decent modules do but many Win32 modules don't :(. For example, check $^E after the call fails (even if they don't document this, since some Win32 API calls will set $^E even if the person writing the module didn't bother to).

            - tye (but my friends call me "Tye")