LdapSettingBase.jsp
19.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
<%@ page import="com.api.integration.ldap.bean.LdapBaseBean" %>
<%@ page import="com.api.integration.ldap.service.LdapService" %>
<%@ page import="com.api.integration.ldap.constant.LdapConstant" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ include file="/systeminfo/init_wev8.jsp" %>
<%@ taglib uri="/WEB-INF/weaver.tld" prefix="wea" %>
<%
if (!HrmUserVarify.checkUserRight(LdapConstant.LDAP_RIGHT_KEY, user)) {
response.sendRedirect("/notice/noright.jsp");
return;
}
String isDialog = Util.null2String(request.getParameter("isdialog"));
String titlename = "LDAP" + SystemEnv.getHtmlLabelName(26267, user.getLanguage());
String operate = Util.null2String(request.getParameter("operate"));
LdapBaseBean ldapBean;
if ("edit".equalsIgnoreCase(operate)) {
String ldapId = Util.null2String(request.getParameter("ldapid"));
LdapService ldapService = new LdapService(user);
ldapBean = ldapService.queryByLdapId(ldapId);
if (ldapBean == null) {
%>
<script>
top.Dialog.alert("<%=SystemEnv.getHtmlLabelName(129113,user.getLanguage())%>", function () {
var parentWin = parent.parent.getParentWindow(parent.window);
parentWin.closeDlgARfsh();
});
</script>
<%
return;
}
} else {
ldapBean = new LdapBaseBean();
//默认驱动类
ldapBean.setFactoryClass("com.sun.jndi.ldap.LdapCtxFactory");
//默认端口
ldapBean.setPort("389");
}
%>
<HTML>
<HEAD>
<LINK href="/css/Weaver_wev8.css" type=text/css rel=STYLESHEET>
<SCRIPT language="javascript" src="/js/weaver_wev8.js"></script>
<link rel="stylesheet" href="/wui/theme/ecology8/weaveredittable/css/WeaverEditTable_wev8.css">
<script src="/wui/theme/ecology8/weaveredittable/js/WeaverEditTable_wev8.js"></script>
<script language="javascript" src="/wui/theme/ecology8/jquery/js/zDialog_wev8.js"></script>
<script language="javascript" src="/wui/theme/ecology8/jquery/js/zDrag_wev8.js"></script>
</head>
<body>
<% if ("1".equals(isDialog)) { %>
<div class="zDialog_div_content">
<% } %>
<%@ include file="/systeminfo/TopTitle_wev8.jsp" %>
<%@ include file="/systeminfo/RightClickMenuConent_wev8.jsp" %>
<%
if (HrmUserVarify.checkUserRight("SystemSetEdit:Edit", user)) {
RCMenu += "{" + SystemEnv.getHtmlLabelName(86, user.getLanguage()) + ",javascript:submitData(),_self} ";
RCMenuHeight += RCMenuHeightStep;
}
%>
<%@ include file="/systeminfo/RightClickMenu_wev8.jsp" %>
<table id="topTitle" cellpadding="0" cellspacing="0">
<tr>
<td></td>
<td class="rightSearchSpan" style="text-align:right; width:500px!important">
<%if (HrmUserVarify.checkUserRight("SystemSetEdit:Edit", user)) {%>
<input type="button" value="<%=SystemEnv.getHtmlLabelName(86 ,user.getLanguage()) %>" class="e8_btn_top"
onclick="submitData()"/>
<%}%>
<span id="advancedSearch" class="advancedSearch"
style='display:none;'><%=SystemEnv.getHtmlLabelName(21995, user.getLanguage()) %></span>
<span title="<%=SystemEnv.getHtmlLabelName(23036 ,user.getLanguage()) %>" class="cornerMenu"></span>
</td>
</tr>
</table>
<div id="tabDiv">
<span style="font-size:14px;font-weight:bold;"><%=titlename%></span>
</div>
<div class="cornerMenuDiv"></div>
<div class="advancedSearchDiv" id="advancedSearchDiv" style='display:none;'></div>
<FORM id="addFrmMain" name="addFrmMain" method=post>
<input type="hidden" name="operate" value="<%=operate%>">
<wea:layout>
<wea:group context='<%=SystemEnv.getHtmlLabelName(82743,user.getLanguage())%>'
attributes="{'samePair':'BaseInfo','groupOperDisplay':'none'}">
<%--是否启用--%>
<wea:item><%=SystemEnv.getHtmlLabelName(26472, user.getLanguage()) %>
</wea:item>
<wea:item>
<input class="inputstyle" type=checkbox tzCheckbox='true' id="isused" name="isused"
<%if(1==ldapBean.getIsUsed())out.println("checked");%> value="1">
</wea:item>
<%--标识--%>
<wea:item><%=SystemEnv.getHtmlLabelName(84, user.getLanguage()) %>
</wea:item>
<wea:item>
<% if ("edit".equalsIgnoreCase(operate)) { %>
<input type="hidden" name="ldapid" id="ldapid" value="<%=ldapBean.getLdapId()%>" />
<span><%=ldapBean.getLdapId()%></span>
<% } else { %>
<wea:required id="ldapidimage" required="true" value="<%=ldapBean.getLdapId()%>">
<input class="inputstyle" style='width:235px!important;' type=text size=50 maxLength="100"
id="ldapid" name="ldapid" value="<%=ldapBean.getLdapId()%>"
onchange='checkinput("ldapid","ldapidimage")' _noMultiLang='true' />
</wea:required>
<% } %>
</wea:item>
<%--名称--%>
<wea:item><%=SystemEnv.getHtmlLabelName(33439, user.getLanguage()) %>
</wea:item>
<wea:item>
<wea:required id="ldapnameimage" required="true" value="<%=ldapBean.getLdapName()%>">
<input class="inputstyle" style='width:235px!important;' type=text size=50 maxLength="100"
id="ldapname" name="ldapname" value="<%=ldapBean.getLdapName()%>"
onchange='checkinput("ldapname","ldapnameimage")' />
</wea:required>
</wea:item>
<%--类型--%>
<wea:item><%=SystemEnv.getHtmlLabelName(63, user.getLanguage()) %>
</wea:item>
<wea:item>
<select style='width:120px!important;' id="ldaptype" name="ldaptype" onchange="javascript:changeldaptype(this.value);" >
<option value="AD" <%
if ("AD".equalsIgnoreCase(ldapBean.getLdapType())) out.println("selected");%>>AD
</option>
<option value="OpenLDAP" <%
if ("OpenLDAP".equalsIgnoreCase(ldapBean.getLdapType())) out.println("selected");%>>OpenLDAP
</option>
<option value="SunOne" <%
if ("SunOne".equalsIgnoreCase(ldapBean.getLdapType())) out.println("selected");%>>SunOne
</option>
</select>
</wea:item>
<%--域名--%>
<wea:item attributes="{'samePair':\"clientdomain\"}">域名
</wea:item>
<wea:item attributes="{'samePair':\"clientdomain\"}">
<wea:required id="domainimage" required="true" value='<%=ldapBean.getDomain()%>'>
<input class="inputstyle" style='width:280px!important;' size=50 maxLength="100"
id="domain" name="domain" value="<%=ldapBean.getDomain()%>"
onchange='checkinput("domain","domainimage")' _noMultiLang='true'/>
</wea:required>
</wea:item>
<%--驱动类--%>
<wea:item><%=SystemEnv.getHtmlLabelName(32285, user.getLanguage()) %>
</wea:item>
<wea:item>
<wea:required id="factoryclassimage" required="true" value='<%=ldapBean.getFactoryClass() %>'>
<input class="inputstyle" style='width:280px!important;' type=text size=50 maxLength="100"
id="factoryclass" name="factoryclass" value="<%=ldapBean.getFactoryClass() %>"
onchange='checkinput("factoryclass","factoryclassimage")' _noMultiLang='true' />
</wea:required>
</wea:item>
<%--启用SSL--%>
<wea:item><%=SystemEnv.getHtmlLabelName(31676, user.getLanguage()) %>SSL</wea:item>
<wea:item>
<input class="inputstyle" type=checkbox tzCheckbox='true' id="isssl" name="isssl" value="1"
<%if("ldaps".equalsIgnoreCase(ldapBean.getProtocol()))out.println("checked");%>
onclick="checkSSLChanged(this);">
</wea:item>
<%--服务器地址--%>
<wea:item><%=SystemEnv.getHtmlLabelName(32286, user.getLanguage()) %>
</wea:item>
<wea:item>
<wea:required id="ipimage" required="true" value="<%=ldapBean.getIp()%>">
<span id="protocol">ldap:// </span>
<input class="inputstyle" style='width:235px!important;' type=text size=50 maxLength="100"
id="ip" name="ip" value="<%=ldapBean.getIp()%>"
onchange='checkinput("ip","ipimage")' _noMultiLang='true' />
</wea:required>
</wea:item>
<%--端口--%>
<wea:item><%=SystemEnv.getHtmlLabelName(84629, user.getLanguage()) %>
</wea:item>
<wea:item>
<wea:required id="portimage" required="true" value='<%=ldapBean.getPort()%>'>
<input class="inputstyle" style='width:40px!important;' type=text size=50 maxLength="10"
id="port" name="port" value="<%=ldapBean.getPort()%>"
onchange='checkinput("port","portimage")' _noMultiLang='true'/>
</wea:required>
</wea:item>
<%--绕过证书--%>
<wea:item attributes="{'samePair':\"isPassingCert\"}"><%=SystemEnv.getHtmlLabelName(132191,user.getLanguage())%>
</wea:item>
<wea:item attributes="{'samePair':\"isPassingCert\"}">
<input class="inputstyle" type=checkbox tzCheckbox='true' id="passingCert" name="passingCert" value="1"
<%if(1==ldapBean.getPassingCert())out.println("checked");%>
onclick="checkPassingCertChanged(this);"
>
</wea:item>
<%--证书路径--%>
<wea:item attributes="{'samePair':\"isssl\"}"><%=SystemEnv.getHtmlLabelName(81795, user.getLanguage())%>
</wea:item>
<wea:item attributes="{'samePair':\"isssl\"}">
<wea:required id="keystorepathimage" required="true" value='<%=ldapBean.getKeystorePath()%>'>
<input class="inputstyle" style='width:280px!important;' type=text size=50 maxLength="100"
id="keystorepath" name="keystorepath" value="<%=ldapBean.getKeystorePath()%>"
onchange='checkinput("keystorepath","keystorepathimage")' _noMultiLang='true'/>
</wea:required>
<!-- 在线导入证书 -->
<input type="button" value="<%=SystemEnv.getHtmlLabelName(131957,user.getLanguage())%>" onClick="doOnlineImportCert();" class="e8_btn_submit"/>
</wea:item>
<%--证书密码--%>
<wea:item attributes="{'samePair':\"isssl\"}"><%=SystemEnv.getHtmlLabelName(81796, user.getLanguage())%>
</wea:item>
<wea:item attributes="{'samePair':\"isssl\"}">
<wea:required id="keystorepasswordimage" required="true" value='<%=ldapBean.getKeystorePassword()%>'>
<input class="inputstyle" style='width:280px!important;' type=password size=50 maxLength="100"
id="keystorepassword" name="keystorepassword" value="<%=ldapBean.getKeystorePassword()%>"
onchange='checkinput("keystorepassword","keystorepasswordimage")' _noMultiLang='true'/>
</wea:required>
</wea:item>
<%--BaseDN\用户名--%>
<wea:item><%=SystemEnv.getHtmlLabelName(2072, user.getLanguage()) %>
</wea:item><!-- 用户名 -->
<wea:item>
<wea:required id="ldapuserimage" required="true" value='<%=ldapBean.getLdapUserForView()%>'>
<input class="inputstyle" style='width:280px!important;' type=text maxLength="255" id="ldapuser"
name="ldapuser" _noMultiLang='true'
value="<%=ldapBean.getLdapUserForView()%>" onchange='checkinput("ldapuser","ldapuserimage")' />
</wea:required>
</wea:item>
<%--密码--%>
<wea:item><%=SystemEnv.getHtmlLabelName(409, user.getLanguage()) %>
</wea:item>
<wea:item>
<wea:required id="ldappasswordimage" required="true" value='<%=ldapBean.getLdapPassword()%>'>
<input class="inputstyle" style='width:280px!important;' type=password maxLength="100"
id="ldappassword" name="ldappassword" value="<%=ldapBean.getLdapPassword()%>"
onchange='checkinput("ldappassword","ldappasswordimage")' _noMultiLang='true' />
</wea:required>
</wea:item>
<%--是否启用ad认证接口--%>
<wea:item><%=SystemEnv.getHtmlLabelName(26472, user.getLanguage()) %>LDAP登录认证
</wea:item>
<wea:item>
<input class="inputstyle" type=checkbox tzCheckbox='true' id="isadaccount" name="isadaccount"
<%if(1==ldapBean.getIsAdAccount())out.println("checked");%> value="1">
</wea:item>
</wea:group>
<%--=============================说明=======================--%>
<wea:group context='<%=SystemEnv.getHtmlLabelName(85,user.getLanguage())%>'
attributes="{'samePair':'RemarkInfo','groupOperDisplay':'none','itemAreaDisplay':'block'}">
<wea:item attributes="{'colspan':'2'}">
<font style="word-break:break-all;">
<br>
1, <%=SystemEnv.getHtmlLabelName(31676, user.getLanguage())
+ "SSL" +
SystemEnv.getHtmlLabelName(131193, user.getLanguage())%><br>
</font>
</wea:item>
</wea:group>
</wea:layout>
</FORM>
<% if ("1".equals(isDialog)) { %>
</div>
<% } %>
<br/><br/><br/><br/>
<div id="zDialog_div_bottom" class="zDialog_div_bottom">
<wea:layout needImportDefaultJsAndCss="false">
<wea:group context="">
<wea:item type="toolbar">
<input class="zd_btn_cancle" type="submit" id="btnClose" onclick="closeWin();"
value="<%=SystemEnv.getHtmlLabelName(309,user.getLanguage())%>"/><!-- 取消 -->
</wea:item>
</wea:group>
</wea:layout>
</div>
</body>
</HTML>
<script>
jQuery(document).ready(function () {
//获取需隐藏\显示的控件标识
var show_name = jQuery("#isssl").attr("id");
if (jQuery("#isssl").attr("checked")) {
jQuery("#protocol").html("ldaps://");
showEle(show_name);
if (jQuery("#passingCert").attr("checked")) {
hideEle("isssl", true);
}
} else {
jQuery("#protocol").html("ldap:// ");
hideEle(show_name, true);
hideEle("isPassingCert", true);
}
if(jQuery("#ldaptype").val()=="AD")
{
showEle("clientdomain");
}
else
{
hideEle("clientdomain");
}
});
/**
* SSL协议切换
*/
function checkSSLChanged(obj) {
//上一次切换状态保存的端口号
var pre_port_value = jQuery("#port").attr("pre_value");
//当前记录的端口号
var port_value = jQuery("#port").val();
//获取需隐藏\显示的控件标识
var show_name = $(obj).attr("id");
if (obj.checked) {
jQuery("#protocol").html("ldaps://");
if (pre_port_value != undefined && pre_port_value != '') {
jQuery("#port").val(pre_port_value);
} else {
jQuery("#port").val("636");
}
showEle(show_name);
showEle("isPassingCert");
} else {
jQuery("#protocol").html("ldap:// ");
if (pre_port_value != undefined && pre_port_value != '') {
jQuery("#port").val(pre_port_value);
} else {
jQuery("#port").val("389");
}
hideEle(show_name, true);
hideEle("isPassingCert");
}
jQuery("#port").attr("pre_value", port_value);
}
/**
* 绕过证书切换
*/
function checkPassingCertChanged(obj) {
if (obj.checked) {
hideEle("isssl", true);
} else {
showEle("isssl");
}
}
/**
* 表单数据提交
*/
function submitData() {
try {
forbiddenPage();
var checkField = "ldapid,ldapname,factoryclass,ldapserverurl,port,ldapuser,ldappassword";
if ($("#isssl").attr("checked") && !$("#passingCert").attr("checked")) {
checkField += ",keystorepath,keystorepassword";
}
if(jQuery("#ldaptype").val()=="AD"){
checkField += ",domain";
}
if (check_form(addFrmMain, checkField)) {
var url = "/api/integration/ldap/add";
if("edit"=="<%=operate%>"){
url = "/api/integration/ldap/edit/" + encodeURIComponent("<%=Util.null2String(request.getParameter("ldapid"))%>");
}
$.ajax({
type: "post",
url: url,
data: $("#addFrmMain").serialize(),
success: function (data) {
releasePage();
data = jQuery.parseJSON(data);
//code == 100表示保存成功,其它都是失败。
if ("100" == data.code) {
closeWinAFrsh();
} else {
top.Dialog.alert(data.description);
}
},
error: function (jqXHR) {
releasePage();
top.Dialog.alert(jqXHR.statusText);
}
});
} else {
releasePage();
}
} catch (e) {
console.log(e);
}
}
function forbiddenPage() {
parent.forbiddenPage();
}
function releasePage() {
parent.releasePage();
}
function closeWin(){
var parentWin = parent.parent.getParentWindow(parent.window);
parentWin.closeDialog();
}
function closeWinAFrsh() {
var parentWin = parent.parent.getParentWindow(parent.window);
parentWin.closeDlgARfsh();
}
function doOnlineImportCert() {
var checkField = "ip,port";
if (check_form(addFrmMain, checkField)) {
window.showModalDialog( "/integration/ldap/ldapcert.jsp?host=" + $GetEle("ip").value + "&port=" + $GetEle("port").value+ "&ldapid=" + $GetEle("ldapid").value,
"<%=SystemEnv.getHtmlLabelName(131957,user.getLanguage())%>",
"dialogWidth:800px;resizable=no;status=no;dialogHeight:600px;dialogLeft:200px;dialogTop:150px;center:yes;help:yes;resizable");
}
}
function changeldaptype(objvalue)
{
var type = objvalue;
if(type=="AD")
{
showEle("clientdomain");
}
else
{
hideEle("clientdomain");
}
}
</script>