<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    Hi!<br>
    <br>
    There is a need to limit the maximum number of AOR for the user.<br>
    To do so:<br>
    <br>
    modparam("registrar", "max_contacts", 1)<br>
    modparam("auth_db", "load_credentials",
    "$avp(loadedip)=domain;$avp(subscriber_username)=username;<big>maxao</big>r")<br>
    <br>
    [user@opensips]# opensipsctl db show subscriber<br>
    id      username        domain  password        email_address  
    ha1     ha1b    rpid    maxaor  quota<br>
    1    202020  77.66.55.44  123456        
    f665ec129cd4556aeed95f3b204ff002    
    888f4df11367b3f2859c4993a4ad7dd3        NULL    <big>1 </big>     
    1<br>
    <br>
    Where: maxaor - maximum number of AOR (max limit).<br>
    <br>
    Next in the config:<br>
    <br>
    if (is_method("REGISTER"))<br>
        {<br>
            if(client_nat_test("8"))<br>
            {<br>
                sl_send_reply("403", "Not working NAT");<br>
                www_challenge("", "0");<br>
                exit;<br>
            }<br>
            # authenticate the REGISTER requests (uncomment to enable
    auth)<br>
            if (!www_authorize("", "subscriber"))<br>
            {<br>
                www_challenge("", "0");<br>
                exit;<br>
            }<br>
            if ($si!=$avp(loadedip))<br>
            {<br>
                www_challenge("", "0");<br>
                exit;<br>
            }<br>
            <big>save("location","c($avp(maxaor))");</big><br>
            if (!db_check_to())<br>
            {<br>
                sl_send_reply("403","Forbidden auth ID");<br>
                exit;<br>
            }<br>
    <br>
            if (!save("location"))<br>
                sl_reply_error();<br>
            exit;<br>
        }<br>
    <br>
    But in the presence of 2 AOR record:<br>
    <br>
    [user@opensips]# opensipsctl ul show 202020<br>
    Contact::
    <a class="moz-txt-link-rfc2396E" href="sip:202020@77.66.55.44;uniq=6041F87C7634A40A246E833DDA15E">&lt;sip:202020@77.66.55.44;uniq=6041F87C7634A40A246E833DDA15E&gt;</a>;q=;expires=1471;flags=0x0;cflags=0x0;socket=&lt;udp:85.85.85.85:5060&gt;;callid=<a class="moz-txt-link-rfc2396E" href="mailto:A8502C3B45165582@192.168.178.1">&lt;A8502C3B45165582@192.168.178.1&gt;</a>;methods=0x3F7F;user_agent=&lt;AVM
    FRITZ!Box Fon WLAN 7140 Annex A 39.04.77 (Feb 14 2014)&gt;<br>
    Contact::
    <a class="moz-txt-link-rfc2396E" href="sip:202020@77.66.55.44:5075">&lt;sip:202020@77.66.55.44:5075&gt;</a>;q=;expires=450;flags=0x0;cflags=0x0;socket=&lt;udp:85.85.85.85:5060&gt;;callid=&lt;5E7D-E2CA-46940374551E59A3ADE4-649@SipHost&gt;;methods=0xFFFFFFFF;user_agent=&lt;204
    12-37-1612531&gt;<br>
    <br>
    Why? What did I do wrong?<br>
    <br>
    Added a check here:<br>
        if ($ct.fields(uri)=~'uniq')<br>
        {<br>
            sl_send_reply("403", "Wrong contact params");<br>
            www_challenge("", "0");<br>
            exit;<br>
        }<br>
    But it seems to me that this is not quite right.....<br>
    Please help!
  </body>
</html>