1 设计思路
1) 具有创建用户、修改用户和删除用户的功能: Administrator
2) 具有创建角色和删除角色的功能: Administrator
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
Static_User字段名 |
详细解释 |
类型 |
备注 |
UserID |
路线编号 |
varchar(20) |
PK |
UserName |
用户名称 |
varchar(20) |
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span> <span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
|
UserPwd |
用户密码 |
varchar(20) |
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span> <span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
|
LastSignTime |
最后登陆时间 |
datatime |
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span> <span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
|
SignState |
用户登陆状态标记 |
int |
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span> <span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
|
TickeID |
验证票记录编号 |
varchar(128) |
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span> <span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
|
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span> <span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
|
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span> <span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
|
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span> <span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
|
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span> <span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
|
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
Static_User字段名 |
详细解释 |
类型 |
备注 |
RoleID |
角色编号 |
varchar(20) |
PK |
RoleName |
角色名称 |
varchar(20) |
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span> <span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
|
RoleNote |
角色信息描述 |
varchar(20) |
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span> <span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
|
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span> <span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
|
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span> <span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
|
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span> <span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
|
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span> <span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
|
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
Static_User字段名 |
详细解释 |
类型 |
备注 |
UserRoleID |
用户角色编号 |
varchar(20) |
PK |
UserID |
用户编号 |
varchar(20) |
FK |
RoleID |
角色编号 |
varchar(20) |
FK |
UserRoleNote |
用户角色信息描述 |
varchar(20) |
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span> <span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
|
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span> <span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
|
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span> <span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
|
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span> <span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
|
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span> <span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
|
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
Static_User字段名 |
详细解释 |
类型 |
备注 |
PermissionID |
编号 |
varchar(20) |
PK |
PermissionName |
权限名称 |
varchar(20) |
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span> <span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
|
PermissionNote |
全息信息描述 |
varchar(20) |
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span> <span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
|
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span> <span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
|
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span> <span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
|
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span> <span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
|
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span> <span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
|
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
Static_User字段名 |
详细解释 |
类型 |
备注 |
RolePermissionID |
角色权限编号 |
varchar(20) |
PK |
RoleID |
角色编号 |
varchar(20) |
FK |
PermissionID |
权限编号 |
varchar(20) |
FK |
RolePermissionNote |
角色权限信息描述 |
varchar(20) |
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span> <span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
|
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span> <span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
|
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span> <span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
|
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span> <span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
|
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span> <span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
|
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
using System.Web.Services;
using System.Web.Services.Protocols;
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
// AuthHeader class extends from SoapHeader
public class AuthHeader : SoapHeader {
public string Username;
public string Password;
}
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
public class HeaderService : WebService {
public AuthHeader sHeader;
...
[WebMethod(Description="This method requires a custom soap header set by the caller")]
[SoapHeader("sHeader")]
public string SecureMethod() {
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
if (sHeader == null)
return "ERROR: Please supply credentials";
else
return "USER: " + sHeader.Username;
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
}
HeaderService h = new HeaderService();
AuthHeader myHeader = new AuthHeader();
myHeader.Username = "username";
myHeader.Password = "password";
h.AuthHeader = myHeader;
String result = h.SecureMethod();
public class ClientClass {
public static void Main() {
GenericIdentity ident = new GenericIdentity("Bob");
GenericPrincipal prpal = new GenericPrincipal(ident,
Newstring[] {"Level1"});
LogicalCallContextData data =
new LogicalCallContextData(prpal);
//Enter data into the CallContext
CallContext.SetData("test data", data);
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
Console.WriteLine(data.numOfAccesses);
ChannelServices.RegisterChannel(new TcpChannel());
RemotingConfiguration.RegisterActivatedClientType(
typeof(HelloServiceClass), "tcp://localhost:8082");
HelloServiceClass service = new HelloServiceClass();
if(service == null) {
Console.WriteLine("Could not locate server.");
return;
}
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
// call remote method
Console.WriteLine();
Console.WriteLine("Calling remote object");
Console.WriteLine(service.HelloMethod("Caveman"));
Console.WriteLine(service.HelloMethod("Spaceman"));
Console.WriteLine(service.HelloMethod("Bob"));
Console.WriteLine("Finished remote object call");
Console.WriteLine();
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
//Extract the returned data from the call context
LogicalCallContextData returnedData =
(LogicalCallContextData)CallContext.GetData("test data");
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
Console.WriteLine(data.numOfAccesses);
Console.WriteLine(returnedData.numOfAccesses);
}
}
using System;
using System.Text;
using System.Runtime.Remoting.Messaging;
using System.Security.Principal;
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
public class HelloServiceClass : MarshalByRefObject {
static int n_instances;
int instanceNum;
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
public HelloServiceClass() {
n_instances++;
instanceNum = n_instances;
Console.WriteLine(this.GetType().Name + " has been created.
Instance # = {0}", instanceNum);
}
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
~HelloServiceClass() {
Console.WriteLine("Destroyed instance {0} of
HelloServiceClass.", instanceNum);
}
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
public String HelloMethod(String name) {
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
//Extract the call context data
LogicalCallContextData data =
(LogicalCallContextData)CallContext.GetData("test data");
IPrincipal myPrincipal = data.Principal;
//Check the user identity
if(myPrincipal.Identity.Name == "Bob") {
Console.WriteLine("\nHello {0}, you are identified!",
myPrincipal.Identity.Name);
Console.WriteLine(data.numOfAccesses);
}
else {
Console.WriteLine("Go away! You are not identified!");
return String.Empty;
}
<span style="font-size: 16px; font-family: 'Microsoft YaHei';"> </span>
// calculate and return result to client
return "Hi there " + name + ".";
}
}
1)class UserInfoMng() 用户信息管理类,其中包括方法:
l CreateUserInfo(string UserName string UserPwd) 建立用户信息,调用存储过程CreateUserInfo(@UserName,@UserPwd)
l ModifyUserInfo(string UserName string UserPwd) 修改用户信息,调用存储过程ModifyUserInfo(@UserName,@UserPwd)
l DeleteUserInfo() 删除用户信息,调用存储过程DeleteUserInfo
(@UserID)
2)class UserAuthentication() 用户认证类,用来实现用户角色、权限的设置,包括方法:
l CreatePermissionInfo(string PermissionName string Permissi-
-onNote) 建立权限信息,调用存储过程CreatePermissionInfo
(@PermissionName,@PermissionNote)
l CreateRoleInfo(string RoleName string RoleNote) 建立角色信息,调用存储过程CreateRoleInfo(@RoleName,@RoleNote)
l DeleteRoleInfo() 删除角色信息,调用存储过程DeleteRoleInfo
(@RoleID)
l GrantUserRole(string UserID string RoleID string UserRoleNote) 授予用户角色,调用存储过程GrantUserRole(@UserID,@RoleID,
@UserRoleNote)
l DeleteUserRole() 删除用户角色,调用存储过程DeleteUserRole
(@UserRoleID)
l GrantRolePermission(string RoleID string PermissionID string RolePermissionNote) 授予角色权限,调用存储过程GrantRolePermission(@RoleID,@PermissionID,@RolePermissionNote)
l DeleteRolePermission() 删除授予的角色权限,调用存储过程
DeleteRolePermission(@RolePermissionID)
1)权限设置
class PermissionInfoMng() 用户权限信息管理类,包括方法:
l CreatePermissionInfo() 建立权限信息
2)用户管理
class UserInfoMng() 用户信息管理类,包括方法:
l CreateUserInfo() 建立用户信息
l ModifyUserInfo() 修改用户信息
l DeleteUserInfo() 删除用户信息
3)用户授权管理
class RoleInfoMng() 角色信息管理类,包括方法:
l CreateRoleInfo() 建立角色信息
l DeleteRoleInfo() 删除角色信息
class UserRoleMng() 用户角色管理类,包括方法:
l GrantUserRole() 授予用户角色
l Del