Implementing a File Transfer Web Service with user authentication (2) (Turn)
Source: Internet
Author: User
Web Author: Cao Www.ASPCool.com time: 2001-11-28 22:50:33 reading times: 520
Second, code implementation
First, we implement a class for authentication, the filename Authentication.cs to the following code:
Using System;
Namespace Useresdata
{
///
Implementing a File Transfer Web Service with user authentication
///
public class Authentication:System.Web.Services.Protocols.SoapHeader
{
public string Username;
public string Password;
Public Boolean ValidUser (String in_username,
String In_password)
{
if ((In_username = = "Caomo") && (In_password = = "Password"))
{
return true;
}
Else
{
return false;
}
}
Public authentication ()
{
//
Todo:add constructor Logic here
//
}
}
}
The authentication class inherits from System.Web.Services.Protocols.SoapHeader. and defines two member variables, username and password, and defines a user-authenticated function ValidUser. It provides functionality for username and password checks, and you can write it very complex, such as checking the user's effectiveness by accessing the database. I'm here to simply check the equality of fixed values.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.