-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
71 additions
and
11 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# Redirect any output to the journal (stderr) | ||
exec 1>&2 | ||
|
||
# Requirement for LDAP | ||
pip install OdooRPC==0.10.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import json | ||
import sys | ||
import os | ||
import odoorpc | ||
from agent.ldapproxy import Ldapproxy | ||
|
||
# Try to parse the stdin as JSON. | ||
# If parsing fails, output everything to stderr | ||
data = json.load(sys.stdin) | ||
|
||
# setup PG values | ||
odoo_host = data.get("odoo_host", "localhost") | ||
odoo_port = os.environ["TCP_PORT"] | ||
odoo_user = data.get("odoo_user", "admin") | ||
odoo_password = data.get("odoo_password", "admin") | ||
odoo_db_name = data.get("odoo_db_name", "odoo") | ||
|
||
# Setup LDAP values | ||
ldap_domain = data.get("ldap_domain", "127.0.0.1") | ||
lp = Ldapproxy() | ||
domain = lp.get_domain(ldap_domain) | ||
|
||
ldap_server = domain.get("host") | ||
ldap_server_port = domain.get("port") | ||
ldap_tls = False | ||
|
||
# Account utente sul server LDAP, utilizzato per interrogare la directory. | ||
# Lasciare vuoto per connettersi in modo anonimo | ||
ldap_binddn = domain.get("bind_dn") | ||
|
||
# Password dell'account utente sul server LDAP, utilizzata per interrogare la directory | ||
ldap_password = domain.get("bind_password") | ||
|
||
# DN dell'ambito di ricerca dell'utente: tutti i discendenti di questa base verranno cercati per gli utenti. | ||
# Enter the domain name of the LDAP server in LDAP nomenclature (e.g. dc=example,dc=com). | ||
ldap_base = domain.get("base_dn") | ||
|
||
# Filtro utilizzato per cercare gli account degli utenti nel database LDAP. | ||
# È un filtro LDAP arbitrario nella rappresentazione delle stringhe. | ||
ldap_filter = "uid=%s" | ||
|
||
odoo = odoorpc.ODOO(odoo_host, port=odoo_port) | ||
odoo.login(odoo_db_name, odoo_user, odoo_password) | ||
|
||
company_id = odoo.env.ref("base.main_company").id | ||
ldap_model = odoo.env["res.company.ldap"] | ||
server_ids = ldap_model.search([]) | ||
for server in ldap_model.browse(server_ids): | ||
server.unlink() | ||
ldap_model.create({ | ||
"company": company_id, | ||
"ldap_server": ldap_server, | ||
"ldap_server_port": ldap_server_port, | ||
"ldap_tls": ldap_tls, | ||
"ldap_binddn": ldap_binddn, | ||
"ldap_password": ldap_password, | ||
"ldap_base": ldap_base, | ||
"ldap_filter": ldap_filter, | ||
}) |