diff options
author | Simon Rettberg | 2016-05-03 19:03:09 +0200 |
---|---|---|
committer | Simon Rettberg | 2016-05-03 19:03:09 +0200 |
commit | 50404f3b23b7fd6aeae4c9d2f6df0ea25e984e66 (patch) | |
tree | 05e99fdffa696434960d7c77966c0bc36d6339e8 /modules-available/sysconfig/templates/ad-selfsearch.html | |
parent | Second half of merge.... (diff) | |
download | slx-admin-50404f3b23b7fd6aeae4c9d2f6df0ea25e984e66.tar.gz slx-admin-50404f3b23b7fd6aeae4c9d2f6df0ea25e984e66.tar.xz slx-admin-50404f3b23b7fd6aeae4c9d2f6df0ea25e984e66.zip |
WIP
Diffstat (limited to 'modules-available/sysconfig/templates/ad-selfsearch.html')
-rw-r--r-- | modules-available/sysconfig/templates/ad-selfsearch.html | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/modules-available/sysconfig/templates/ad-selfsearch.html b/modules-available/sysconfig/templates/ad-selfsearch.html new file mode 100644 index 00000000..76952dc3 --- /dev/null +++ b/modules-available/sysconfig/templates/ad-selfsearch.html @@ -0,0 +1,112 @@ +<p> + {{lang_dnLookup}} +</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><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}} + <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="" type="hidden"> + <input id="givendn" name="originalbinddn" value="{{binddn}}" 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}} + <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) { + domain = $('#givendn').val().replace(/[\/\\]\S+$/i, ''); + var idx = fulldn.search(new RegExp('\\w+=' + domain + ',', "i")); + console.log(idx); + if (idx !== -1) { + search = fulldn.substring(idx); + } + $('#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 + || (tryHomeAttr && $('#home').val().length === 0 && $('#homeattr').val().length === 0 && attrlist.length === 0)) { + $('#nextbutton').html('{{lang_continueAnyway}}'); + } 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}}'); + } + $('#nextbutton').show(); + } + + function slxSetHomeAttr(sel) { + $('#homeattr').val(sel.options[sel.selectedIndex].value); + } +</script> |