blob: 64e181b22e833e1a1536fe7959bc50290f8aee95 (
plain) (
tree)
|
|
<p>
{{#tryHomeAttr}}
{{lang_determiningHomeDirectory}}
{{/tryHomeAttr}}
{{^tryHomeAttr}}
{{lang_dnLookup}}
{{/tryHomeAttr}}
</p>
<p>
{{binddn}} @ {{server}}<br>
SearchBase: {{searchbase}}
</p>
<div id="zeug">
<div data-tm-id="{{self-search}}" data-tm-log="messages" data-tm-callback="selfCb">LDAP Self-Query</div>
<pre style="display:none" id="result"></pre>
<div style="display:none" id="haselect">
<div class="slx-bold">{{lang_selectHomeAttribute}}</div>
{{lang_homeAttributeExplanation}}
</div>
</div>
<i>{{lang_onProblemSearchBase}}</i>
<br>
<div class="alert alert-warning" id="nohome" style="display:none">
{{lang_noHomeAttrFound}}
</div>
<br>
<div class="pull-left">
<form role="form" method="post" action="?do=SysConfig&action=addmodule&step={{prev}}">
<input type="hidden" name="token" value="{{token}}">
<input type="hidden" name="edit" value="{{edit}}">
<input name="title" value="{{title}}" type="hidden">
<input name="server" value="{{server}}" type="hidden">
<input name="searchbase" value="{{searchbase}}" type="hidden">
<input name="binddn" value="{{binddn}}" type="hidden">
<input name="bindpw" value="{{bindpw}}" type="hidden">
<input name="home" value="{{home}}" type="hidden">
<input name="homeattr" value="{{homeattr}}" type="hidden">
{{#ssl}}
<input name="ssl" value="on" type="hidden">
<input type="hidden" name="certificate" value="{{certificate}}">
{{/ssl}}
{{#mapping}}
<input type="hidden" name="mapping[{{field}}]" value="{{value}}">
{{/mapping}}
<input name="fixnumeric" value="{{fixnumeric}}" type="hidden">
<button type="submit" class="btn btn-primary">« {{lang_back}}</button>
</form>
</div>
<div class="pull-right">
<form id="nextform" role="form" method="post" action="?do=SysConfig&action=addmodule&step={{next}}">
<input type="hidden" name="token" value="{{token}}">
<input type="hidden" name="edit" value="{{edit}}">
<input name="title" value="{{title}}" type="hidden">
<input name="server" value="{{server}}" type="hidden">
<input name="port" value="{{port}}" type="hidden">
<input id="searchbase" name="searchbase" value="{{searchbase}}" type="hidden">
<input id="fulldn" name="binddn" value="{{binddn}}" type="hidden">
<input id="givendn" name="originalbinddn" value="{{originalbinddn}}" type="hidden">
<input name="bindpw" value="{{bindpw}}" type="hidden">
<input id="home" name="home" value="{{home}}" type="hidden">
<input id="homeattr" name="homeattr" value="{{homeattr}}" type="hidden">
{{#ssl}}
<input name="ssl" value="on" type="hidden">
<input type="hidden" name="certificate" value="{{certificate}}">
{{/ssl}}
{{#mapping}}
<input type="hidden" name="mapping[{{field}}]" value="{{value}}">
{{/mapping}}
<input name="fixnumeric" value="{{fixnumeric}}" type="hidden">
<input name="fingerprint" value="{{fingerprint}}" type="hidden">
<button id="nextbutton" type="submit" class="btn btn-primary" style="display:none">{{lang_skip}} »</button>
</form>
</div>
<script type="text/javascript">
function selfCb(task)
{
if (!task || !task.statusCode || task.statusCode === 'TASK_WAITING' || task.statusCode === 'TASK_PROCESSING')
return;
if (task.statusCode === 'TASK_FINISHED' && task.data && task.data.dn) {
var fulldn = task.data.dn;
var domain = "-";
var search = $('#searchbase').val();
if ($('#searchbase').val().length < 2) {
var givenDn = $('#givendn').val();
if (new RegExp('^([^\\[\\]\\:;\\|\\=\\+\\?\\<\\>\\*"/\\\\,]+)[/\\\\]([^\\[\\]\\:;\\|\\=\\+\\?\\<\\>\\*"/\\\\,]+)$').test(givenDn)) {
domain = givenDn.replace(/[\/\\]\S+$/i, '');
var idx = fulldn.search(new RegExp('\\w+=' + domain + ',', "i"));
if (idx !== -1) {
search = fulldn.substring(idx);
}
} else {
var idx = givenDn.toLowerCase().indexOf(',dc=');
if (idx !== -1) {
search = givenDn.substring(idx + 1);
}
}
$('#searchbase').val(search);
}
$('#fulldn').val(fulldn);
$('#result').text("BindDN: " + fulldn + "\nWinDomain: " + domain + "\nSearchBase: " + search).show();
var attrlist = [];
var tryHomeAttr = false;
{{#tryHomeAttr}}
tryHomeAttr = true;
if (task.data.home && task.data.home.length) attrlist = task.data.home;
{{/tryHomeAttr}}
if (typeof search !== 'string' || search.length === 0 || search.length + 2 >= fulldn.length) {
$('#nextbutton').html('{{lang_continueAnyway}}');
} else if (tryHomeAttr && $('#home').val().length === 0 && $('#homeattr').val().length === 0 && attrlist.length === 0) {
$('#nextbutton').html('{{lang_continueAnyway}}');
$('#nohome').show();
} else if (attrlist.length > 1 && $('#homeattr').val().length === 0) {
var sel = $('<select>').attr('onchange', 'slxSetHomeAttr(this)').addClass('form-control');
var best = 0;
for (var i = 1; i < attrlist.length; ++i) {
if (attrlist[i].score > attrlist[best].score) best = i;
}
for (var i = 0; i < attrlist.length; ++i) {
var opt = $('<option>').attr('value', attrlist[i].attr).text(attrlist[i].attr + ' (' + attrlist[i].value + ')');
if (i === best) opt.attr('selected', 'selected');
sel.append(opt);
}
$('#haselect').append(sel).append('<br>').show();
slxSetHomeAttr(sel[0]);
$('#nextbutton').html('{{lang_next}}');
} else {
if (attrlist.length === 1 && $('#homeattr').val().length === 0) {
$('#homeattr').val(attrlist[0].attr);
}
$('#nextform').submit();
}
} else {
$('#nextbutton').html('{{lang_continueAnyway}}');
$('#zeug').append('<div>Debug:</div>').append( $('<pre></pre>').text(JSON.stringify(task, null, 3)) );
}
$('#nextbutton').show();
}
function slxSetHomeAttr(sel) {
$('#homeattr').val(sel.options[sel.selectedIndex].value);
}
</script>
|