anchor.diff: +%%%-------------------------------------------------------------------
  +%%% File    : sipuserdb_ldap.erl
  +%%% Author  : Fredrik Thulin
  +%%% Descrip.: A sipuserdb module with an LDAP backend.
  +%%%
  +%%% Created : 09 Oct 2003 by Fredrik Thulin <ft@it.su.se>
  +%%%-------------------------------------------------------------------
   -module(sipuserdb_ldap).
  --export([yxa_init/0,
  +
  +%%--------------------------------------------------------------------
  +%% External exports
  +%%--------------------------------------------------------------------
  +-export([
  +	 yxa_init/0,
   	 get_user_with_address/1,
   	 get_users_for_address_of_record/1,
   	 get_users_for_addresses_of_record/1,
  
positive.code: 	    end
      end.
  
  get_users_for_AOR_list(Server, UserAttribute, AddressAttribute, []) ->
      [];
  get_users_for_AOR_list(Server, UserAttribute, AddressAttribute, [Address | Rest]) ->
      Res = directory:ldapsearch_simple(Server, AddressAttribute, Address, UserAttribute),
      case Res of
  	error ->
  	    error;
  	none ->
  	    get_users_for_AOR_list(Server, UserAttribute, AddressAttribute, Rest);
  	Users when list(Users) ->
  	    lists:append(Users, get_users_for_AOR_list(Server, UserAttribute, AddressAttribute, Rest))
      end.
  
  
  % Gets all addresses for a user. Used for example
  % to check if a request from a user has an acceptable
  % From: header.
  get_addresses_for_user(User) ->
      get_addresses_for_users([User]).
  
  get_addresses_for_users(UserList) ->
      case sipserver:get_env(ldap_server, none) of
  	none ->
  	    nomatch;
  
negative.code: 	]).
  
  
  %%--------------------------------------------------------------------
  %% Include files
  %%--------------------------------------------------------------------
  -include("siprecords.hrl").
  
  %%====================================================================
  %% External functions
  %%====================================================================
  
  %%--------------------------------------------------------------------
  %% Function: yxa_init()
  %% Descrip.: Perform any necessary startup initialization and
  %%           return an OTP supervisor child spec if we want to add
  %%           to sipserver_sup's list. If this sipuserdb_module
  %%           needs to be persistent, it should be a gen_server and
  %%           init should just return a spec so that the gen_server
  %%           is started by the supervisor.
  %% Returns : Spec |
  %%           []
  %%           Spec = OTP supervisor child specification
  %%--------------------------------------------------------------------
  yxa_init() ->
      [].
  
  %%--------------------------------------------------------------------
  %% Function: get_user_with_address(Address)
  %%           Address = string(), an address in string format.
  %% Descrip.: Looks up exactly one user with an Address. Used for
  %%           example in REGISTER. If there are multiple users with
  %%           this address in our database, this function returns
  %%           'error'.
  %% Returns:  Username |
  %%           nomatch  |
  %%           error
  %%           Username = string()
  %%--------------------------------------------------------------------
  get_user_with_address(Address) ->
      case sipserver:get_env(ldap_server, none) of
  	none ->
  