<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="ValidateUser.asp" -->
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE><%=Application("WebTitle")%>-UserMgr.asp</TITLE>
<%	
	GetUserRole Request.QueryString("username"), Request.QueryString("password"), "UserMgr.asp"

	if Session("UserRole") < 2 then
		Session("ErrorMsg") = "Sorry,you are common user and haven't authority of administrator!"
		Response.Redirect("Error.asp")
	end if
	
	dim KVWebUserManager
	if Request.QueryString("opt") = "Add" then	
		set KVWebUserManager = Server.CreateObject("KVWebSvr.UserManager")
		if not KVWebUserManager is Nothing then
			if KVWebUserManager.AddUser(Request.QueryString("name"), Request.QueryString("pwd"), Request.QueryString("desc"), Request.QueryString("role")) = 0 then
				set KVWebUserManager = Nothing
				Session("ErrorMsg") = "Sorry,Fail to add user!Please check network configuration,or contact administrator."
				Response.Redirect("Error.asp")
			end if
			set KVWebUserManager = Nothing
		end if					
	ElseIf Request.QueryString("opt") = "Del" then		
		set KVWebUserManager = Server.CreateObject("KVWebSvr.UserManager")
		if not KVWebUserManager is Nothing then
			if KVWebUserManager.DeleteUser(Request.QueryString("name")) = 0 then
				set KVWebUserManager = Nothing
				Session("ErrorMsg") = "Sorry,Fail to delete user!Please check network configuration,or contact administrator."
				Response.Redirect("Error.asp")
			end if
			set KVWebUserManager = Nothing
		end if		
	end if
%>
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--

function DKVWebUserMgr1_OnAddUser() {
	window.navigate("UserMgr.asp?opt=Add&name=" + DKVWebUserMgr1.UserName + "&pwd=" + DKVWebUserMgr1.Password + "&desc=" + DKVWebUserMgr1.Description + "&role=" + DKVWebUserMgr1.UserRole);
}

function DKVWebUserMgr1_OnDeleteUser() {
	window.navigate("UserMgr.asp?opt=Del&name=" + DKVWebUserMgr1.UserName);
}
function DKVWebUserMgr1_OnCancel() {
	window.navigate("Default.asp");
}

//-->
</SCRIPT>
<SCRIPT LANGUAGE=javascript FOR=DKVWebUserMgr1 EVENT=OnCancel>
<!--
 DKVWebUserMgr1_OnCancel()
//-->
</SCRIPT>
<SCRIPT LANGUAGE=javascript FOR=DKVWebUserMgr1 EVENT=OnAddUser>
<!--
 DKVWebUserMgr1_OnAddUser()
//-->
</SCRIPT>
<SCRIPT LANGUAGE=javascript FOR=DKVWebUserMgr1 EVENT=OnDeleteUser>
<!--
 DKVWebUserMgr1_OnDeleteUser()
//-->
</SCRIPT>
</HEAD>
<BODY>
<P align=center><STRONG><%=Application("WebTitle")%><FONT size=2>-</FONT></STRONG><FONT 
size=2>User management</FONT>
<DIV align=center>
<HR>
</DIV>
<P align=center>
<OBJECT id=DKVWebUserMgr1 style="WIDTH: 80%; HEIGHT: 90%" height="90%"  codebase=".\Controls\KVWeb.cab#$KVWebUserMgr.ocx$#"
width="80%" classid=clsid:CB306B57-3688-4423-AF07-FB1110D2E6D0 codebase=".\Controls\KVWeb.cab"><PARAM NAME="_Version" VALUE="65536"><PARAM NAME="_ExtentX" VALUE="15796"><PARAM NAME="_ExtentY" VALUE="13229"><PARAM NAME="_StockProps" VALUE="1"><PARAM NAME="BackColor" VALUE="16777215"><param name="CmdSvrIP" value=<%=Application("CmdSvrIP")%>><param name="CmdSvrPort" value=<%=Application("CmdSvrPort")%>><param name="FileSvrIP" value=<%=Application("FileSvrIP")%>><param name="FileSvrPort" value=<%=Application("FileSvrPort")%>><param name="FSvrVirtualDir" value=<%=Application("FSvrVirtualDir")%>></OBJECT>
</P>

</BODY>
</HTML>
