Method: JSS::LDAPServer#find_user

Defined in:
lib/jss/api_object/ldap_server.rb

#find_user(user, exact = false) ⇒ Array<Hash>

Search for a user in this ldap server

Parameters:

  • user (String)

    the username to search for

  • exact (Boolean) (defaults to: false)

    if true, force an exact match, otherwise use wildcards

Returns:

  • (Array<Hash>)

    The mapped LDAP data for all usernames matching the query

Raises:



303
304
305
306
307
# File 'lib/jss/api_object/ldap_server.rb', line 303

def find_user(user, exact = false)
  raise JSS::NoSuchItemError, 'LDAPServer not yet saved in the JSS' unless @in_jss
  raw = api.get_rsrc("#{RSRC_BASE}/id/#{@id}/user/#{CGI.escape user.to_s}")[:ldap_users]
  exact ? raw.select { |u| u[:username] == user } : raw
end