We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40055
    • 4 Posts
    I am new to modx and using it to create a website for our department at work. Fot this site we will have public facing general information along with private material that one must login to see.

    I followed this tutorial on setting up "member's only" pages:
    http://rtfm.modx.com/display/revolution20/Making+Member-Only+Pages

    Using useful information I found about the Login snippet I found here:
    http://rtfm.modx.com/display/ADDON/Login.Login

    I then created the following chunk with an "IF" snippet call that prints whose (not) logged in and a login/login link.
    [[!If?
       &subject=`[[+modx.user.id]]`
       &operator=`EQ`
       &operand=`0`
       &then=`<b>Not Logged In</b> &nbsp <a href="[[~34]]" id="login" title="logout">(login)</a>`
       &else=`logged in as: &nbsp &nbsp<b>[[+modx.user.username]]</b> &nbsp <a href="[[~34 &service=logout]]" id="logout" title="logout">(logout)</a>`
    ]]


    After manually clearing the cache from the from the manager, it works great for the first login. After I follow the "logout" link, the user is logged out, but the username displayed (with the associated logout link) is still displayed on any page I visited while logged in as that user. If I go back and clear the cache, it works again for the first login.

    It seems like this is due to the username/id not flushing/reseting in the cache after a logout, but perhaps it is something to do with my "if" conditional?

    Once I have this working correctly, I would also like to restrict access to static resources (namely a Sphinx documentation site) I am linking to, based on the user's login status. The only way I have thought of doing this is by using Active Directory/LDAP authentication to modx, then also having AD/LDAP authentication to the directory that the site/resource resides in. Is there a better way of doing this?

    In addition what is the best way of authenicating to modx using a Linux LDAP server?


    Thanks for the help!!!

    Some helpful info
    ----------------------------------------------
    Web Server:
    * PHP 5.3.3
    * Apache 2.2.3
    * CentosOS release 5.6

    Database:
    * mysql Ver 14.12 Distrib 5.0.77, for redhat-linux-gnu (x86_64) using readline 5.1

    MODx:
    * MODX Revolution 2.2.0-pl2 (traditional)
    * Using plugin: TinyMCE, GalleryCustomTV
    * Installed but not 'using': ActiveDirectory, ldapAuth

    Browser/Client:
    * Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9.2.18) Gecko/20110622 CentOS/3.6-1.el5.centos Firefox/3.6.18
      • 40055
      • 4 Posts
      Just checking to see if anybody has suggestion on how I should reword this to encourage response. Thanks for the help.
        • 22303 MODX Staff
        • 10,725 Posts
        Try not caching the placeholders in your If tag...
        [[!+modx.user.id]]

        [[!+modx.user.username]]
          • 40055
          • 4 Posts
          Awesome. That looks like it did the trick. I learned about caching a few days ago, but I only omitted caching on the id (the if conditional), which didn't take care of it.

          As for LDAP, is it possible to use the AD extension, or is there another solution folks use for authenticating through a non-AD LDAP server? I'm new to such things and was hoping to get steared down the right path.

          Thanks!!!
            • 40055
            • 4 Posts
            I found this LDAP plugin following links in various forum posts, so I thought I would post it here in the event somebody arrives here with my same question. I'll post with my experience here. Thanks again for the help!

            https://forums.modx.com/index.php/topic,44833.0.html