[solved] LDAP error: local variable 'conn' referenced before assignment

After a fresh frappe install using sudo python install.py --production command and following this instruction I get error: local variable 'conn' referenced before assignment error when trying to set LDAP settings.

OS: Debian GNU/Linux 8.10 (jessie)
ERPNext: v10.0.6 (master)
Frappe Framework: v10.0.7 (master)

UPDATE:
Setting following test settings. it seams to work will try to play with parameters.

LDAP Server Url: ldap://ldap.forumsys.com:389
Organizational Unit: dc=example,dc=com

Base Distinguished Name (DN): cn=read-only-admin,dc=example,dc=com
Password for Base DN: password

LDAP Search String: uid={0}
LDAP First Name Field: cn
LDAP Email Field: mail
LDAP Username Field: uid

Error report:

App Versions
{
	"erpnext": "10.0.6",
	"frappe": "10.0.7"
}
Route
Form/LDAP Settings/LDAP Settings
Error Report
Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/save.py", line 22, in savedocs
    doc.save()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 256, in save
    return self._save(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 290, in _save
    self.run_before_save_methods()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 859, in run_before_save_methods
    self.run_method("validate")
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 755, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1024, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1007, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 749, in 
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/integrations/doctype/ldap_settings/ldap_settings.py", line 14, in validate
    self.validate_ldap_credentails()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/integrations/doctype/ldap_settings/ldap_settings.py", line 31, in validate_ldap_credentails
    conn.unbind_s()
UnboundLocalError: local variable 'conn' referenced before assignment

Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 62, in application
    response = frappe.handler.handle()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 22, in handle
    data = execute_cmd(cmd)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 53, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 939, in call
    return fn(*args, **newargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/desk/form/save.py", line 22, in savedocs
    doc.save()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 256, in save
    return self._save(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 290, in _save
    self.run_before_save_methods()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 859, in run_before_save_methods
    self.run_method("validate")
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 755, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1024, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 1007, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 749, in 
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/integrations/doctype/ldap_settings/ldap_settings.py", line 14, in validate
    self.validate_ldap_credentails()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/integrations/doctype/ldap_settings/ldap_settings.py", line 31, in validate_ldap_credentails
    conn.unbind_s()
UnboundLocalError: local variable 'conn' referenced before assignment
Request Data
{
	"type": "POST",
	"args": {
		"doc": "{\"modified_by\":\"Administrator\",\"name\":\"LDAP Settings\",\"creation\":\"2018-01-08 18:55:29.986105\",\"enabled\":0,\"modified\":\"2018-01-08 18:55:29.986105\",\"idx\":\"0\",\"doctype\":\"LDAP Settings\",\"owner\":\"Administrator\",\"docstatus\":0,\"__last_sync_on\":\"2018-01-08T13:34:46.280Z\",\"ldap_server_url\":\"dc-ldap\",\"__unsaved\":1,\"base_dn\":\"CN=****,OU=main,DC=*********,DC=local\",\"ldap_search_string\":\"sAMAccountName={0}\",\"password\":\"*****\",\"organizational_unit\":\"OU=main,DC=**********,DC=local\",\"ldap_first_name_field\":\"cn\",\"ldap_email_field\":\"mail\",\"ldap_username_field\":\"uid\"}",
		"action": "Save",
		"cmd": "frappe.desk.form.save.savedocs"
	},
	"btn": {
		"jQuery224088345037618837211": {
			"events": {
				"click": [
					{
						"type": "click",
						"origType": "click",
						"guid": 161,
						"namespace": ""
					}
				]
			}
		}
	},
	"freeze": true,
	"freeze_message": "Saving",
	"url": "/"
}

SOLVED:

LDAP Server Url had to be in a form like ldap://address instead of just address.