<%
'获得某个管理员的权限列表
function getPrivilegeList(adminName)
	dim rsPrivilege
	set rsPrivilege=server.createobject("adodb.recordset")
  	rsPrivilege.open "select role.privilege from role,admin where admin.RoleId=role.id and admin.UserName='"&adminName&"'",conn,3,1
	if not rsPrivilege.eof then
		getPrivilegeList=rsPrivilege(0)
	else
		getPrivilegeList="错误！没有找到关于"&adminName&"的记录"
	end if
	rsPrivilege.close
	set rsPrivilege=nothing
end function
'检查是否有指定的权限
function checkPrevilege(adminName,previlegeStr)	
	if(not checkIfHasPrevilege(adminName,previlegeStr)) then
		response.Write("<script>alert('您没有此权限!');location.href=""login.asp"";</script>")
	end if
end function
'检查是否有指定的权限
function checkIfHasPrevilege(adminName,previlegeStr)
	dim rsCheckPrevilege,uPreList
	checkIfHasPrevilege=false
	set rsCheckPrevilege=server.createobject("adodb.recordset")
  	rsCheckPrevilege.open "select RoleId from admin where UserName='"&adminName&"'",conn,3,1
	if not rsCheckPrevilege.eof then
		if(Cint(rsCheckPrevilege(0))=0) then'如果是超级管理员
			checkIfHasPrevilege=true
		else
			uPreList=getPrivilegeList(adminName)
			if (uPreList<>"") and (previlegeStr<>"") then
				if InStr(uPreList,previlegeStr)<> 0 then
					checkIfHasPrevilege = True
				else
					checkIfHasPrevilege = False
				end if
			else
				checkIfHasPrevilege = False
			end if
		end if
	else
		checkIfHasPrevilege=false
	end if	
	rsCheckPrevilege.close
	set rsCheckPrevilege=nothing
end function
%>