⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cswebservicebase.cs

📁 本系统是在asp版《在线文件管理器》的基础上设计制作
💻 CS
字号:
//------------------------------------------------------------------------------
// <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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -