diff options
| author | luisgulo <luisgulo@gmail.com> | 2025-10-24 18:01:10 +0200 |
|---|---|---|
| committer | luisgulo <luisgulo@gmail.com> | 2025-10-24 18:01:10 +0200 |
| commit | 533e79ba959143f0459431a486bfb85c56c72ddc (patch) | |
| tree | 91974de1bbbdc4c51c76ed591fc5c6e02a3342b6 /community_modules/ldap | |
| parent | 45019c81cfd0fc1d18dce18cdfd5f127c6d61073 (diff) | |
Releasing code version 1.8.0
Diffstat (limited to 'community_modules/ldap')
| -rw-r--r-- | community_modules/ldap/ldap_ad.sh | 71 | ||||
| -rw-r--r-- | community_modules/ldap/ldap_ad.tr.en | 7 | ||||
| -rw-r--r-- | community_modules/ldap/ldap_ad.tr.es | 7 | ||||
| -rw-r--r-- | community_modules/ldap/ldap_openldap.sh | 72 | ||||
| -rw-r--r-- | community_modules/ldap/ldap_openldap.tr.en | 7 | ||||
| -rw-r--r-- | community_modules/ldap/ldap_openldap.tr.es | 7 |
6 files changed, 171 insertions, 0 deletions
diff --git a/community_modules/ldap/ldap_ad.sh b/community_modules/ldap/ldap_ad.sh new file mode 100644 index 0000000..361b7fb --- /dev/null +++ b/community_modules/ldap/ldap_ad.sh @@ -0,0 +1,71 @@ +#!/bin/bash +# Module: ldap_ad +# Description: Realiza búsquedas filtradas en servidores Active Directory usando ldapsearch +# License: GPLv3 +# Author: Luis GuLo +# Version: 1.1.0 +# Dependencies: ldapsearch + +ldap_ad_task() { + local host="$1" + shift + + check_dependencies_ldap_ad || return 1 + + local state="" server="" port="389" base_dn="" filter="" attributes="" bind_dn="" password="" + for arg in "$@"; do + case "$arg" in + state=*) state="${arg#state=}" ;; + server=*) server="${arg#server=}" ;; + port=*) port="${arg#port=}" ;; + base_dn=*) base_dn="${arg#base_dn=}" ;; + filter=*) filter="${arg#filter=}" ;; + attributes=*) attributes="${arg#attributes=}" ;; + bind_dn=*) bind_dn="${arg#bind_dn=}" ;; + password=*) password="${arg#password=}" ;; + esac + done + + # 🌐 Cargar traducciones + local lang="${shflow_vars[language]:-es}" + local trfile="$(dirname "${BASH_SOURCE[0]}")/ldap_ad.tr.${lang}" + declare -A tr + if [[ -f "$trfile" ]]; then while IFS='=' read -r k v; do tr["$k"]="$v"; done < "$trfile"; fi + + if [[ "$state" != "search" ]]; then + echo "$(render_msg "${tr[unsupported_state]}" "state=$state")" + return 1 + fi + + if [[ -z "$server" || -z "$base_dn" || -z "$filter" ]]; then + echo "${tr[missing_args]:-❌ [ldap_ad] Faltan argumentos obligatorios: server, base_dn, filter}" + return 1 + fi + + echo "$(render_msg "${tr[connecting]}" "server=$server" "port=$port")" + local cmd=(ldapsearch -LLL -H "$server" -p "$port" -b "$base_dn" "$filter") + [[ -n "$bind_dn" && -n "$password" ]] && cmd=(-D "$bind_dn" -w "$password" "${cmd[@]}") + [[ -n "$attributes" ]] && IFS=',' read -ra attr_list <<< "$attributes" && cmd+=("${attr_list[@]}") + + if "${cmd[@]}" 2>/tmp/ldap_ad_error.log | grep -E '^(dn:|cn:|mail:|sAMAccountName:)' ; then + echo "${tr[success]:-✅ [ldap_ad] Búsqueda completada con éxito}" + else + echo "${tr[no_results]:-⚠️ [ldap_ad] No se encontraron resultados o hubo un error}" + cat /tmp/ldap_ad_error.log + return 1 + fi +} + +check_dependencies_ldap_ad() { + local lang="${shflow_vars[language]:-es}" + local trfile="$(dirname "${BASH_SOURCE[0]}")/ldap_ad.tr.${lang}" + declare -A tr + if [[ -f "$trfile" ]]; then while IFS='=' read -r k v; do tr["$k"]="$v"; done < "$trfile"; fi + + if ! command -v ldapsearch &>/dev/null; then + echo "${tr[missing_dep]:-❌ [ldap_ad] El comando 'ldapsearch' no está disponible}" + return 1 + fi + echo "${tr[deps_ok]:-✅ [ldap_ad] Dependencias OK}" + return 0 +} diff --git a/community_modules/ldap/ldap_ad.tr.en b/community_modules/ldap/ldap_ad.tr.en new file mode 100644 index 0000000..55214ae --- /dev/null +++ b/community_modules/ldap/ldap_ad.tr.en @@ -0,0 +1,7 @@ +unsupported_state=❌ [ldap_ad] Unsupported state: '{state}'. Only 'search' is allowed +missing_args=❌ [ldap_ad] Missing required arguments: server, base_dn, filter +connecting=🔍 [ldap_ad] Connecting to {server}:{port}... +success=✅ [ldap_ad] Search completed successfully +no_results=⚠️ [ldap_ad] No results found or an error occurred +missing_dep=❌ [ldap_ad] 'ldapsearch' command is not available +deps_ok=✅ [ldap_ad] Dependencies OK diff --git a/community_modules/ldap/ldap_ad.tr.es b/community_modules/ldap/ldap_ad.tr.es new file mode 100644 index 0000000..93dca53 --- /dev/null +++ b/community_modules/ldap/ldap_ad.tr.es @@ -0,0 +1,7 @@ +unsupported_state=❌ [ldap_ad] Estado no soportado: '{state}'. Solo se permite 'search' +missing_args=❌ [ldap_ad] Faltan argumentos obligatorios: server, base_dn, filter +connecting=🔍 [ldap_ad] Conectando a {server}:{port}... +success=✅ [ldap_ad] Búsqueda completada con éxito +no_results=⚠️ [ldap_ad] No se encontraron resultados o hubo un error +missing_dep=❌ [ldap_ad] El comando 'ldapsearch' no está disponible +deps_ok=✅ [ldap_ad] Dependencias OK diff --git a/community_modules/ldap/ldap_openldap.sh b/community_modules/ldap/ldap_openldap.sh new file mode 100644 index 0000000..bfe8a85 --- /dev/null +++ b/community_modules/ldap/ldap_openldap.sh @@ -0,0 +1,72 @@ +#!/bin/bash +# Module: ldap_openldap +# Description: Realiza búsquedas filtradas en servidores OpenLDAP usando ldapsearch +# License: GPLv3 +# Author: Luis GuLo +# Version: 1.1.0 +# Dependencies: ldapsearch + +ldap_openldap_task() { + local host="$1" + shift + + check_dependencies_ldap_openldap || return 1 + + local state="" server="" port="389" base_dn="" filter="" attributes="" bind_dn="" password="" + for arg in "$@"; do + case "$arg" in + state=*) state="${arg#state=}" ;; + server=*) server="${arg#server=}" ;; + port=*) port="${arg#port=}" ;; + base_dn=*) base_dn="${arg#base_dn=}" ;; + filter=*) filter="${arg#filter=}" ;; + attributes=*) attributes="${arg#attributes=}" ;; + bind_dn=*) bind_dn="${arg#bind_dn=}" ;; + password=*) password="${arg#password=}" ;; + esac + done + + # 🌐 Cargar traducciones + local lang="${shflow_vars[language]:-es}" + local trfile="$(dirname "${BASH_SOURCE[0]}")/ldap_openldap.tr.${lang}" + declare -A tr + if [[ -f "$trfile" ]]; then while IFS='=' read -r k v; do tr["$k"]="$v"; done < "$trfile"; fi + + if [[ "$state" != "search" ]]; then + echo "$(render_msg "${tr[unsupported_state]}" "state=$state")" + return 1 + fi + + if [[ -z "$server" || -z "$base_dn" || -z "$filter" ]]; then + echo "${tr[missing_args]:-❌ [ldap_openldap] Faltan argumentos obligatorios: server, base_dn, filter}" + return 1 + fi + + echo "$(render_msg "${tr[connecting]}" "server=$server" "port=$port")" + local cmd=(ldapsearch -x -H "$server:$port") + [[ -n "$bind_dn" && -n "$password" ]] && cmd+=(-D "$bind_dn" -w "$password") + cmd+=(-b "$base_dn" "$filter") + [[ -n "$attributes" ]] && IFS=',' read -ra attr_list <<< "$attributes" && cmd+=("${attr_list[@]}") + + if "${cmd[@]}" 2>/tmp/ldap_error.log | grep -E '^(dn:|cn:|mail:|uid:)' ; then + echo "${tr[success]:-✅ [ldap_openldap] Búsqueda completada con éxito}" + else + echo "${tr[no_results]:-⚠️ [ldap_openldap] No se encontraron resultados o hubo un error}" + cat /tmp/ldap_error.log + return 1 + fi +} + +check_dependencies_ldap_openldap() { + local lang="${shflow_vars[language]:-es}" + local trfile="$(dirname "${BASH_SOURCE[0]}")/ldap_openldap.tr.${lang}" + declare -A tr + if [[ -f "$trfile" ]]; then while IFS='=' read -r k v; do tr["$k"]="$v"; done < "$trfile"; fi + + if ! command -v ldapsearch &>/dev/null; then + echo "${tr[missing_dep]:-❌ [ldap_openldap] El comando 'ldapsearch' no está disponible}" + return 1 + fi + echo "${tr[deps_ok]:-✅ [ldap_openldap] Dependencias OK}" + return 0 +} diff --git a/community_modules/ldap/ldap_openldap.tr.en b/community_modules/ldap/ldap_openldap.tr.en new file mode 100644 index 0000000..9868fb5 --- /dev/null +++ b/community_modules/ldap/ldap_openldap.tr.en @@ -0,0 +1,7 @@ +unsupported_state=❌ [ldap_openldap] Unsupported state: '{state}'. Only 'search' is allowed +missing_args=❌ [ldap_openldap] Missing required arguments: server, base_dn, filter +connecting=🔍 [ldap_openldap] Connecting to {server}:{port}... +success=✅ [ldap_openldap] Search completed successfully +no_results=⚠️ [ldap_openldap] No results found or an error occurred +missing_dep=❌ [ldap_openldap] 'ldapsearch' command is not available +deps_ok=✅ [ldap_openldap] Dependencies OK diff --git a/community_modules/ldap/ldap_openldap.tr.es b/community_modules/ldap/ldap_openldap.tr.es new file mode 100644 index 0000000..62a649b --- /dev/null +++ b/community_modules/ldap/ldap_openldap.tr.es @@ -0,0 +1,7 @@ +unsupported_state=❌ [ldap_openldap] Estado no soportado: '{state}'. Solo se permite 'search' +missing_args=❌ [ldap_openldap] Faltan argumentos obligatorios: server, base_dn, filter +connecting=🔍 [ldap_openldap] Conectando a {server}:{port}... +success=✅ [ldap_openldap] Búsqueda completada con éxito +no_results=⚠️ [ldap_openldap] No se encontraron resultados o hubo un error +missing_dep=❌ [ldap_openldap] El comando 'ldapsearch' no está disponible +deps_ok=✅ [ldap_openldap] Dependencias OK |
