<% javascript 'auth_source_ldap' %>

<%= form_for @auth_source_ldap do |f| %>
  <%= base_errors_for @auth_source_ldap %>
  <ul class="nav nav-tabs" data-tabs="tabs">
    <li class="active"><a href="#primary" data-toggle="tab"><%= _("LDAP server") %></a></li>
    <li><a href="#account" data-toggle="tab"><%= _("Account") %></a></li>
    <li><a href="#attributes" data-toggle="tab"><%= _("Attribute mappings") %></a></li>
  </ul>

  <div class="tab-content">
    <div class="tab-pane active" id="primary">
      <%= text_f f, :name %>
      <%= text_f f, :host %>
      <%= checkbox_f(f, :tls, {:label => "LDAPS", :onchange => 'change_ldap_port(this)'}) %>
      <%= number_f f, :port, :min => 1, :max => 65535,
                      :data => { :default_ports => AuthSourceLdap::DEFAULT_PORTS } %>
      <%= select_f f, :server_type, AuthSourceLdap::SERVER_TYPES, :first, :last,
                    { :include_blank => _("Choose a server type") },
                    { :label => _('Server type') } %>
    </div>
    <div class="tab-pane" id="account">
      <%= text_f f, :account, :help_inline =>_("Use this account to authenticate, <i>optional</i>").html_safe %>
      <%= password_f f, :account_password, :help_inline => _("Use this account to authenticate, <i>optional</i>").html_safe %>
      <%= text_f f, :base_dn, :label => _("Base DN"), :size => "col-md-8" %>
      <%= text_f f, :groups_base, :label => _("Groups base DN") %>
      <%= text_f f, :ldap_filter, :label => _("LDAP filter"), :help_inline => _("Custom LDAP search filter, <i>optional</i>").html_safe, :size => "col-md-8" %>
      <%= checkbox_f f, :onthefly_register,
                        :help_inline => _("LDAP users will have their Foreman account automatically created the first time they log into Foreman") %>
      <%= checkbox_f f, :usergroup_sync,
                        :help_inline => _("External user groups will be synced on login, else relies on periodic cronjob to check group membership") %>
    </div>
    <div class="tab-pane" id="attributes">
      <%= text_f f, :attr_login, :help_inline => _("e.g. uid") %>
      <%= text_f f, :attr_firstname, :help_inline => _("e.g. givenName") %>
      <%= text_f f, :attr_lastname, :help_inline => _("e.g. sn") %>
      <%= text_f f, :attr_mail, :help_inline => _("e.g. mail") %>
      <%= text_f f, :attr_photo, :label => _("Photo attribute"), :help_inline => _("e.g. jpegPhoto") %>
    </div>
  </div>

  <%= submit_or_cancel f %>
<% end %>
