anchor.diff:  		    nomatch;
   		[{dn, Dn, attributes, EAttributes}] ->
   		    case directory:get_value(EAttributes, UserAttribute) of
  -			QRes when list(QRes) ->
  +			QRes when is_list(QRes) ->
   			    logger:log(debug, "userdb-ldap: Found LDAP user for ~p, dn ~p: ~p", [Address, Dn, QRes]),
   			    QRes;
   			Foo ->
   			    logger:log(debug, "userdb-ldap: Query for exactly one user matching address ~p failed (~p)",
  -					[Address, Foo]),
  +				       [Address, Foo]),
   			    error
   		    end;
  -		[{dn, Dn, attributes, EAttributes} | Rest] ->
  +		[{dn, _Dn, attributes, _EAttributes} | _Rest] ->
   		    logger:log(debug, "userdb-ldap: Query for exactly one user matching address ~p failed, multiple users found",
  -		    		[Address]),
  +			       [Address]),
   		    error;
   		Unknown ->
   		    logger:log(debug, "userdb-ldap: Query for exactly one user matching address ~p failed, ldapsearch returned : ~p",
  -		    		[Address, Unknown]),
  +			       [Address, Unknown]),
   		    error
   	    end
       end.
   
  -% Looks up all users with a given address. Used
  -% to find out to which users we should send a request.
  -% Other userdb types than mnesia might perform multiple lookups.
  -get_users_for_address_of_record(Address) ->
  +%%--------------------------------------------------------------------
  +%% Function: get_users_for_address_of_record(Address)
  +%%           Address = string(), an address in string format.
  +%% Descrip.: Get all usernames of users matching an address. Used to
  +%%           find out to which users we should send a request.
  +%% Returns : Users   |
  +%%           nomatch |
  +%%           error
  +%%           Users = list() of string() 
  +%%--------------------------------------------------------------------
  +get_users_for_address_of_record(Address) when is_list(Address) ->
       get_users_for_addresses_of_record([Address]).
   
  -get_users_for_addresses_of_record(AddressList) ->
  +%%--------------------------------------------------------------------
  +%% Function: get_users_for_addresses_of_record(Addresses)
  +%%           Addresses = list() of string(), addresses in string
  +%%                       format.
  +%% Descrip.: Iterate over a list of addresses of record, return
  +%%           all users matching one or more of the addresses,
  +%%           without duplicates.
  +%% Returns : Users   |
  +%%           nomatch |
  +%%           error
  +%%           Users = list() of string() 
  +%%--------------------------------------------------------------------
  +get_users_for_addresses_of_record(AddressList) when is_list(AddressList) ->
       case sipserver:get_env(ldap_server, none) of
   	none ->
   	    nomatch;
  
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: 		none ->
  		    logger:log(debug, "userdb-ldap: Found no telephone number for user ~p", [User]),
  		    nomatch;
  		[Number] when is_list(Number) ->
  		    Number
  	    end
      end.
  
  %%--------------------------------------------------------------------
  %% Function: get_forwards_for_users(Usernames)
  %%           Usernames = list() of string()
  %% Descrip.: Should return a list of forwards for a list of users.
  %%           This is not yet implemented in the LDAP userdb. XXX FIX.
  %%           The reason it isn't implemented is because we (SU)
  %%           haven't decided on how to represent forwards in the LDAP
  %%           schema. XXX we haven't? Isn't this "sipRoutingAddress"?
  %% Returns : nomatch
  %%--------------------------------------------------------------------
  get_forwards_for_users(_Usernames) ->
      logger:log(debug, "userdb-ldap: Forwards are not yet implemented in the LDAP userdb module"),
      nomatch.
  
  %%--------------------------------------------------------------------
  %% Function: get_forward_for_user(Username)
  %%           Username = string()
  %% Descrip.: Should return the forward address for a user.
  %%           This is not yet implemented in the LDAP userdb. XXX FIX.
  %%           The reason it isn't implemented is because we (SU)
  %%           haven't decided on how to represent forwards in the LDAP
  %%           schema. XXX we haven't? Isn't this "sipRoutingAddress"?
  %% Returns : nomatch
  %%--------------------------------------------------------------------
  get_forward_for_user(_User) ->
      logger:log(debug, "userdb-ldap: Forwards are not yet implemented in the LDAP userdb module"),
      nomatch.
  
  