cswebservicebase.cs
来自「本系统是在asp版《在线文件管理器》的基础上设计制作」· CS 代码 · 共 74 行
CS
74 行
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
// Copyright (c) Telligent Systems Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System;
using System.Collections;
using System.Security;
using System.Web.Services;
using System.Web.Services.Protocols;
namespace CommunityServer.Components
{
/// <summary>
/// Summary description for CSWebServiceBase.
/// </summary>
public abstract class CSWebServiceBase : WebService
{
public CSWebServiceBase()
{
}
public class ServiceCredentials : SoapHeader {
public string Username;
public string Password;
public string SectionName;
}
protected void LoginSetSection() {
Login();
AllocateSection();
}
protected void Login() {
if(Globals.IsNullorEmpty(Credentials.Username) || Globals.IsNullorEmpty(Credentials.Password))
throw new SecurityException("Invalid (or unsupplied) Username, or Password");
User u = new User();
u.Username = Credentials.Username;
u.Password = Credentials.Password;
LoginUserStatus status = Users.ValidUser(u);
if(status == LoginUserStatus.Success) {
System.Web.Security.FormsAuthentication.SetAuthCookie(u.Username,false);
CurrentUser = Users.GetUser(-1,u.Username,false,false);
CSContext.Current.User = CurrentUser;
}
else
throw new SecurityException("Invalid User Credentials");
}
protected abstract void AllocateSection();
protected User CurrentUser = null;
public ServiceCredentials Credentials = new ServiceCredentials();
[WebMethod(MessageName="Validate",Description="Validates a users credentials for a specific Section",EnableSession=false)]
[SoapHeader("Credentials")]
public bool Validate()
{
LoginSetSection();
return true;
}
[WebMethod(MessageName="Ping",Description="Enables pinging to see if the site is online",EnableSession=false,CacheDuration=3600)]
public void Ping()
{
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?