<%@ page contentType="text/html;charset=gbk" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="java.sql.*" %>
<%@ page import="net.sz600.ldap.*" %>
<%@ page import="net.sz600.tool.SzConvert" %>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<link href="../../images/skin2_blue2/css2007.css" rel="stylesheet" type="text/css">
</head>
<%
  String type = SzConvert.toZeroStr(request.getParameter("type2"));
  String user = SzConvert.strWriteData(request.getParameter("user"));
  String password = SzConvert.strWriteData(request.getParameter("password"));
  String name = SzConvert.strWriteData(request.getParameter("name"));
  String s = "";
  LdapConn ldapConn = new LdapConn();
  boolean flag = false;

  if (type.equals("1")) {
    flag = ldapConn.isSystemUser(user, password);
    if (flag) {
      s = "合法用户";
    } else {
      s = "非法用户";
    }
  } else if (type.equals("2")) {
    flag = ldapConn.addUser(user, password, name);
    if (flag) {
      s = "添加用户成功";
    } else {
      s = "添加用户成功";
    }
  }
  
%>
<div align="center">
<form method="post" name="form" action="ldap.jsp">
登陆帐号：<input type="text" name="user" value="<%=user%>"><br>
登陆密码：<input type="text" name="password" value="<%=password%>"><br>
用户名称：<input type="text" name="name" value="<%=name%>"><br>
<input type="hidden" name="type2" value="0">
<input type="button" value="验证用户" onClick="submit2(1);">
<input type="button" value="新增用户" onClick="submit2(2);">
<input type="reset" value="重设">
<br>
<%=s%>
</form>
</div>

<script language="javascript">

  function submit2(type) {
    form.type2.value = type;
    form.action="ldap.jsp";
    form.submit();
  }

</script>