summaryrefslogblamecommitdiffstats
path: root/modules-available/sysconfig/templates/ad_ldap-checkconnection.html
blob: e686c29f047c19812b48b1ddcfb8af1a0b85b824 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
   
                               


               
                                                                                                        
      


                                                                                                  

                                                                                                              
    
                       
                                                                                                      
                                                                    
                                                                  
                                                                    



                                                                              
                                                                  
                                                                          
                        

                                                                                
                        



                                                                                         
                                                                              
                                                                      
                                                                                            

               
                        
                                                                                                                    
                                                                    
                                                                  
                                                                    
                                                                      
                                                                    
                                                                              
                                                                      
                                                                      
                                                                  
                                                                          
                        
                                                                    
                                                                                  
                                                                                                 
                        


                                                                                         
                                                                              
                                                                      
                                                                              
                                                                                                                                 

               
                    
                               

                                   








                                                              
         
                               


                                              


                                                                                          
                                        

                                                                                  
                                                                

                                                                                                                                                                           
                                                

                                                                                          
                                                                                                                                                    
                                                                                                                                    

                                                                                                                                                                      

                                                                                        






                                                                                                 
                                 
                                                              
                         











                                                                           
                                                        
                                                                                     

                                                                      
                         
                 
         
         
<p>
	{{lang_connectionWait}}
</p>

<div id="zeug">
	<div data-tm-id="{{taskid}}" data-tm-log="messages" data-tm-callback="portScan">Port Check</div>
</div>
<div id="self-signed" style="display:none" class="alert alert-info">{{lang_selfSignedNote}}</div>
<div id="no-valid-cert" style="display:none" class="alert alert-danger">{{lang_noValidCert}}</div>
<div id="no-open-port" style="display:none" class="alert alert-danger">{{lang_noOpenPort}}</div>
<div id="supplied-cert-invalid" style="display:none" class="alert alert-danger">{{lang_userCertInvalid}}</div>
<div id="trying-fingerprint" style="display:none" class="alert alert-warning">{{lang_tryingFingerprint}}</div>
<br>
<div class="text-left">
	<form role="form" method="post" action="?do=SysConfig&amp;action=addmodule&amp;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">
		<input name="genuid" value="{{genuid}}" type="hidden">
		<button type="submit" class="btn btn-primary">&laquo; {{lang_back}}</button>
	</form>
</div>
<div class="text-right">
	<form id="nextform" role="form" method="post" action="?do=SysConfig&amp;action=addmodule&amp;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 id="port" name="port" value="" 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 id="ssl" name="ssl" value="on" type="hidden">
		<input id="fingerprint" name="fingerprint" value="" type="hidden">
		<input id="certificate" 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="genuid" value="{{genuid}}" type="hidden">
		<input name="originalbinddn" value="{{binddn}}" type="hidden">
		<button id="nextbutton" type="submit" class="btn btn-primary" style="display:none">{{lang_next}} &raquo;</button>
	</form>
</div>
<div id="bla"></div>
<script type="text/javascript">
	function isSelfSigned(code)
	{
		return code == 19;
	}
	function isIncomplete(code)
	{
		return code == 18 || code == 20 || code == 21;
	}
	function isValid(code)
	{
		return code == 0;
	}
	function portScan(task)
	{
		if (!task || !task.statusCode)
			return;
		if (task.statusCode === 'TASK_FINISHED' && task.data && task.data.ports) {
			var ssl = $('#ssl').length > 0;
			var ports = task.data.ports;
			var verRes = -1;
			var userCert = ssl && $('#certificate').val().length > 10;
			var openPort = false;
			for (var i = 0; i < ports.length; ++i) {
				if (!ports[i].open || !ports[i].port) continue;
				if ($.isNumeric($('#port').val()) && $('#port').val() < ports[i].port) continue; // Prefer the global LDAP ports over the specific AD ports
				openPort = true;
				if (ssl) {
					if (verRes === -1) verRes = ports[i].verifyResult;
					if (typeof ports[i].certFingerprint !== 'string' || typeof ports[i].certificateChain !== 'string') continue;
					if (ports[i].certFingerprint.length < 10 || ports[i].certificateChain.length < 10) continue;
					if (!isValid(ports[i].verifyResult) && userCert) continue;
					if (!isValid(ports[i].verifyResult) && !isSelfSigned(ports[i].verifyResult) && !isIncomplete(ports[i].verifyResult)) continue;
					verRes = ports[i].verifyResult;
					$('#fingerprint').val(ports[i].certFingerprint);
					if (!userCert && isSelfSigned(verRes)) {
						$('#certificate').val(ports[i].certificateChain);
					} else if (!userCert && isValid(verRes)) {
						$('#certificate').val('default');
					} else if (!userCert) {
						$('#certificate').val('');
					}
				}
				$('#port').val(ports[i].port);
			}
			if (openPort && ssl && !isValid(verRes)) {
				if (userCert) {
					$('#supplied-cert-invalid').show();
				} else if (isSelfSigned(verRes)) {
					$('#self-signed').show();
				} else if (isIncomplete(verRes)) {
					$('#trying-fingerprint').show();
				} else {
					$('#no-valid-cert').show();
				}
			}
			if (openPort) {
				$('#nextbutton').show();
				if (!ssl || isValid(verRes)) $('#nextform').submit();
			} else {
				$('#no-open-port').css('display', '');
			}
		}
	}
</script>