From: Robert Lowe (Robert.H.Lowe@lawrence.edu)
Date: Wed Feb 04 2004 - 11:36:46 CST
Charles Scheidecker wrote:
> Robert Lowe wrote:
>
>>
>>
>> Baron M Rawlins wrote:
>>
>>> I'm ashamed to say it, but we never looked into changing the IMAP
>>> auth code, maybe we'll get around to that over spring break?
>>> Instead, our helpdesk staff simply sends a test email to student, and
>>> then they register okay.
>>
>>
>>
>> Well, perhaps Bruce can verify for us. :-) I did find documentation
>> for Net::IMAP::Simple, but it's rather sparse. I didn't ever plan on
>> using this auth method, and since I didn't write it, I never tested it.
>> It would be nice to clean up the code though...
>>
>> -Robert
>>
>>> ----- Original Message -----
>>> From: Robert Lowe <mailto:Robert.H.Lowe@lawrence.edu>
>>> To: netreg@southwestern.edu <mailto:netreg@southwestern.edu>
>>> Sent: Friday, January 23, 2004 10:29 AM
>>> Subject: Re: NetReg: Authentication failed error
>>>
>>>
>>>
>>> Baron M Rawlins wrote:
>>>
>>> > I had the same problem here a while ago (Netreg 1.3rc2 / IMAP
>>> auth) > Turned out that the authentication function returned the
>>> number of
>>> > messages in the users Inbox.
>>> > The students authenticated successfully, but had zero messages.
>>> Thus the
>>> > 'authentication failed' message when allive==0 or !alive,
>>> depending on
>>> > your code.
>>>
>>> So, how did you resolve this? I assume alive returns a negative
>>> value
>>> when authentication fails? If so, then the code should mimick
>>> what is
>>> there for POP authentication.
>>>
>>> -Robert
>
> I got this to work by changing the following lines:
>
> elsif ($AUTH_METHOD eq "IMAP") {
> $imap = new Net::IMAP::Simple( "$IMAPSERVER" );
> $alive = $imap->login( $FORM{'user'}, $FORM{'pass'} );
> $imap->quit();
> unless ($alive) {
> error("Authentication Failed");
> }
> }
>
> to this:
>
> elsif ($AUTH_METHOD eq "IMAP") {
> $imap = new Net::IMAP::Simple( "$IMAPSERVER" );
> $alive = $imap->login( "$FORM{'user'}\@wartburg.edu", $FORM{'pass'} );
> $alive = $imap->mailboxes();
> $imap->quit();
> unless ($alive) {
> error("Authentication Failed<P>Please check that you have
> entered your Username and Password correctly.");
> }
> }
>
> Getting a count of how many mailboxes are present is a much more
> accurate way to determine if the connection was successful, because it
> will always return at least 1 if it was a success - at least with the
> IMAP system we're using, which is Imail from Ipswitch. Hope you all
> find this helpful.
Charles,
I decided to lay this issue to rest... I looked at the login() method
in Net::IMAP::Simple.
sub login {
my ( $self, $user, $pass ) = @_;
my ( $sh, $id, $resp );
$sh = $self->{sock};
$id = $self->_nextid();
print $sh "$id LOGIN $user $pass\r\n";
$resp = $sh->getline();
if ( $resp =~ /^$id\s+OK/i ) {
return $self->select( 'INBOX' );
}
return;
}
The select('INBOX') call returns the number of messages in the INBOX
when authentication succeeds. I recall others in the past ensuring
that the inbox had at least one message. Another way of treating the
symptom, rather than getting at the root cause!
Your method may not be much better, since it assumes that at least
one mailbox, the inbox, is created when you create an IMAP account,
which may or may not happen, and perhaps again, sending a message
may do the same.
Change the unless clause to:
unless (defined $alive) {
error ("...");
}
One call, clean and simple... could you confirm or deny that this works?
-Robert
**********************************************************************
To unsubscribe from this list, send an e-mail message to
majordomo@southwestern.edu containing a single line with the words:
unsubscribe netreg
Send requests for assistance to: owner-netreg@southwestern.edu
**********************************************************************
This archive was generated by hypermail 2.1.4 : Thu Aug 12 2004 - 12:01:43 CDT