Sha256: cdf38e5f7ba0643cf42e11af33c7c1186a038a6ed5e46c556e5a5b6d8c4ebc62

Contents?: true

Size: 1.09 KB

Versions: 7

Compression:

Stored size: 1.09 KB

Contents

require 'conjur/command'

class Conjur::Command::LDAPSync < Conjur::Command
  desc 'LDAP sync management commands'
  command :'ldap-sync' do |cgrp|

    cgrp.desc 'Manage the policy used to sync Conjur and the LDAP server'
    cgrp.command :policy do |policy|

      policy.desc 'Show the current policy'
      policy.command :show do |show|

        show.desc 'LDAP Sync profile to use (defined in UI)'
        show.arg_name 'profile'
        show.flag ['p', 'profile'], default_value: 'default'

        show.action do |_,options,_|
          begin
            resp = api.ldap_sync_policy(config_name: options[:profile])
            
            if (policy = resp['policy'])
              if resp['ok']
                puts(policy)
              else
                exit_now! 'Failed creating the policy.'
              end
            else
              exit_now! resp['error']['message']
            end
          rescue RestClient::ResourceNotFound => ex
            exit_now! "LDAP sync is not supported by the server #{Conjur.configuration.appliance_url}"
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
conjur-cli-6.2.6 lib/conjur/command/ldap_sync.rb
conjur-cli-6.2.5 lib/conjur/command/ldap_sync.rb
conjur-cli-6.2.4 lib/conjur/command/ldap_sync.rb
conjur-cli-6.2.3 lib/conjur/command/ldap_sync.rb
conjur-cli-6.2.2 lib/conjur/command/ldap_sync.rb
conjur-cli-6.2.1 lib/conjur/command/ldap_sync.rb
conjur-cli-6.2.0 lib/conjur/command/ldap_sync.rb