From 92e6bb8975df1a127e17e2e4ad86f5ad583fa8e2 Mon Sep 17 00:00:00 2001 From: Geert Josten Date: Fri, 22 May 2015 11:56:23 +0200 Subject: [PATCH] Figured out how to use ldap simple method --- deploy/lib/xquery/setup.xqy | 54 +++++++++++++++++++++++++++++++++++++ deploy/ml-config.xml | 5 ++-- 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/deploy/lib/xquery/setup.xqy b/deploy/lib/xquery/setup.xqy index 2b41a90..c434ad2 100644 --- a/deploy/lib/xquery/setup.xqy +++ b/deploy/lib/xquery/setup.xqy @@ -308,6 +308,21 @@ declare variable $field-settings := word-searches ; +declare variable $external-security-settings := + + authentication + authorization + cache-timeout + description + ldap-attribute + ldap-base + ldap-bind-method + ldap-default-user + ldap-password + ldap-server-uri + name + ; + (: A note on naming conventions: $admin-config refers to the configuration passed around by the Admin APIs $import-config is the import/export configuration format that setup:get-configuration() generates @@ -442,6 +457,7 @@ declare function setup:do-setup($import-config as element(configuration)+) as it setup:create-roles($import-config), setup:create-users($import-config), setup:create-external-security($import-config), + setup:apply-external-security-settings($import-config), setup:create-mimetypes($import-config), setup:create-groups($import-config), setup:configure-groups($import-config), @@ -4271,6 +4287,44 @@ declare function setup:create-external-security( ) }; +declare function setup:apply-external-security-settings($import-config as element(configuration)) as item()* +{ + for $es-config in $import-config/sec:external-securities/sec:external-security + let $es-name := $es-config/sec:external-security-name + let $apply-settings := + for $setting in $external-security-settings/*:setting + let $setting-test := + if ($setting/@accept-blank = "true") then + "" + else + "[fn:string-length(fn:string(.)) > 0]" + let $value := + if ($setting/@value) then + xdmp:value($setting/@value) + else + fn:data(xdmp:value(fn:concat("$es-config/sec:", $setting, $setting-test))) + let $min-version as xs:string? := $setting/@min-version + where (fn:exists($value)) + return + if (fn:empty($min-version) or setup:at-least-version($min-version)) then + xdmp:eval( + fn:concat(' + xquery version "1.0-ml"; + import module namespace sec = "http://marklogic.com/xdmp/security" at "/MarkLogic/security.xqy"; + declare variable $value external; + sec:external-security-set-', fn:replace($setting, 'external-security-', ''), '("', $es-name, '", $value) + '), + (xs:QName("value"), $value), + {$default-security} + ) + else + fn:error( + xs:QName("VERSION_NOT_SUPPORTED"), + fn:concat("MarkLogic ", xdmp:version(), " does not support ", $setting, ". Use ", $min-version, " or higher.")) + return + fn:concat("External security ", $es-name, " settings applied succesfully.") +}; + declare function setup:validate-external-security( $import-config as element(configuration)) { diff --git a/deploy/ml-config.xml b/deploy/ml-config.xml index 2139204..696396d 100644 --- a/deploy/ml-config.xml +++ b/deploy/ml-config.xml @@ -745,13 +745,14 @@ marklogic-ldap Authentication against MarkLogic LDAP ldap - 999999999 + 300 ldap ldap://ldap.marklogic.com:3268 OU=Employees,OU=CORP,DC=marklogic,DC=com sAMAccountName - @ml.ldap-user + CN=@ml.ldap-user,OU=Employees,OU=CORP,DC=marklogic,DC=com @ml.ldap-password + simple