Q:

Unable to retrieve archived messages from new session

I am using EjabberD and have enabled MAM using 
  mod_mam:  
      default: always

I am able to retrieve only the messages I have sent using the client on the current session. If I logout and login again on the client, all the archived messages are deleted from the DB. (acertained by comparing Mnesia dumps before and after the second login).  
I am using Strophe js based client. 
The IQ Packet sent for getting the archived messages
<iq type="set" to="user1@x.x.x.x" xmlns="jabber:client" id="c0104a00-253e-4727-9157-a4ea24d9bc86:sendIQ">
    <query xmlns="urn:xmpp:mam:2">
        <x xmlns="jabber:x:data" type="submit">
            <field var="FORM_TYPE" type="hidden">
                <value>urn:xmpp:mam:2</value>
            </field>
            <field var="with">
                <value>user1@x.x.x.x</value>
            </field>
        </x>
        <set xmlns="http://jabber.org/protocol/rsm" />
    </query>
</iq>

On strophe i logout from the server using 
connection.disconnect();
connection.reset();

EDIT : Authentication mechanism is LDAP and ANON.
host_config:
  "x.x.x.x":
    auth_method:
        - anonymous
        - ldap
    allow_multiple_connections: false
    ldap_servers:
        - "x.x.x.x"
    ldap_encrypt: none
    ldap_port: 389
    ldap_base: "cn=Users,dc=x,dc=x,dc=x"
    ldap_rootdn: "cn=Administrator,cn=Users,dc=x,dc=x,dc=x"
    ldap_password: "xxx"

    ldap_uids:
        - "sAMAccountName": "%u"

I want the messages to be archived forever. So that the clients can retrieve the history without storing anything locally. What am I missing?

A:

Are those accounts anonymous? If so, they are deleted when they logout, and all their related information is also deleted, like roster and mam messages.

