class Lita::Handlers::Ldap

Public Instance Methods

cmd_check_filter(response) click to toggle source
# File lib/lita/handlers/ldap.rb, line 129
def cmd_check_filter(response)
  filter_string = response.matches[0][1]
  #puts "filter_string: #{filter_string}"
  if ! filter_string.nil? && filter_string.strip.length>0
    is_valid = valid_filter?(filter_string)
    if is_valid
      response.reply "Filter is valid."
    else
      response.reply "Filter in not valid."
    end
  else
    response.reply "Filter string is empty."
  end
end
cmd_delete_tree_with_dn(response) click to toggle source
# File lib/lita/handlers/ldap.rb, line 187
def cmd_delete_tree_with_dn(response)
  dn = response.matches[0][1]
  if ! dn.nil? && dn.strip.length>0
    begin
      success = delete_tree_by_dn(dn)
      if success
        response.reply "Entry deleted."
      else
        response.reply "Failed to delete entry."
      end
    rescue Exception => e
      response.reply e.message
    end
  else
    response.reply "Invalid dn provided."
  end
end
cmd_delete_with_dn(response) click to toggle source
# File lib/lita/handlers/ldap.rb, line 169
def cmd_delete_with_dn(response)
  dn = response.matches[0][1]
  if ! dn.nil? && dn.strip.length>0
    begin
      success = delete_entry_by_dn(dn)
      if success
        response.reply "Entry deleted."
      else
        response.reply "Failed to delete entry, server may not support LDAP control 1.2.840.113556.1.4.805."
      end
    rescue Exception => e
      response.reply e.message
    end
  else
    response.reply "Invalid dn provided."
  end
end
cmd_search_group(response) click to toggle source
# File lib/lita/handlers/ldap.rb, line 122
def cmd_search_group(response)
  search_string = response.matches[0][0]
  #logger.debug "searching group with #{search_string}"
  results = search_group(search_string)
  response.reply results
end
cmd_search_user(response) click to toggle source
# File lib/lita/handlers/ldap.rb, line 115
def cmd_search_user(response)
  search_string = response.matches[0][0]
  #logger.info "searching user with #{search_string}"
  results = search_user(search_string)
  response.reply results
end
cmd_search_with_dn(response) click to toggle source
# File lib/lita/handlers/ldap.rb, line 159
def cmd_search_with_dn(response)
  dn = response.matches[0][1]
  if ! dn.nil? && dn.strip.length>0
    results = get_entry_by_dn(dn)
    response.reply results
  else
    response.reply "Invalid dn provided."
  end
end
cmd_search_with_filter(response) click to toggle source
# File lib/lita/handlers/ldap.rb, line 144
def cmd_search_with_filter(response)
  filter_string = response.matches[0][1]
  if ! filter_string.nil? && filter_string.strip.length>0
    is_valid = valid_filter?(filter_string)
    if is_valid
      results = search_with_filter(filter_string)
      response.reply results
    else
      response.reply "Filter in not valid."
    end
  else
    response.reply "Filter string is empty."
  end
end
cmd_show_root_dse(response) click to toggle source
# File lib/lita/handlers/ldap.rb, line 205
def cmd_show_root_dse(response)
  results = search_root_dse
  response.reply results
end