Results 1 to 7 of 7

Thread: Extending com.zimbra.cs.account.ldap.LdapProvisioning in ZCS 8.x

  1. #1
    amessina's Avatar
    amessina is offline Active Member
    Join Date
    Jun 2007
    Location
    Campobello di Mazara, Italy
    Posts
    38
    Rep Power
    7

    Default Extending com.zimbra.cs.account.ldap.LdapProvisioning in ZCS 8.x

    I have this class:

    Code:
    public class MyProvisioning extends LdapProvisioning {
    
        public MyProvisioning() {
            super();
            ZimbraLog.account.info("[MyProvisioning] MyProvisioning() constructor");
        }    
    
        @Override
        public Account get(AccountBy keyType, String key, boolean loadFromMaster) throws ServiceException {
            ZimbraLog.account.info("[MyProvisioning] get(AccountBy keyType, String key, boolean loadFromMaster) method");
            Account acct = super.get(keyType, key, loadFromMaster);
            return acct;
        }
    }
    If I assing it as a new zimbra_class_provisioning via zmlocalconfig it works as expected in ZCS 7.x: the get() method is always called when a user lookup occours.

    In ZCS 8.x I can see just the constructor log message and it seems that my get() method is never called.

    Does anyone know why?

    TIA,
    Antonio

  2. #2
    yutaka is offline Project Contributor
    Join Date
    Oct 2009
    Location
    Tokyo
    Posts
    113
    Rep Power
    5

    Default

    You know that there are some get() methods and every methods has different patterns of parameters.

    When you send AuthRequest/SOAP, "get(AccountBy keyType, String key, boolean loadFromMaster)" is called.
    But you send GetAccount/SOAP for admin, "get(AccountBy keyType, String key, AuthToken authToken)" is called.

    So it might help us if you tell us what exactly you are doing when you said "a user lookup occours".

  3. #3
    amessina's Avatar
    amessina is offline Active Member
    Join Date
    Jun 2007
    Location
    Campobello di Mazara, Italy
    Posts
    38
    Rep Power
    7

    Default

    Quote Originally Posted by yutaka View Post
    When you send AuthRequest/SOAP, "get(AccountBy keyType, String key, boolean loadFromMaster)" is called.
    This one, called when a user tries to authenticate.

    As previously said, in 7.x it works and thanks to it I've done the lazy autoprovisioning mechanism for AD found in ADProvision | Zimbra :: Gallery (fyi: source code for the real class ADProvisioning.java - adpassword - Active Directory users autoprovisioning extension for Zimbra - Google Project Hosting).

    Obviously that extension is not useful in 8.x, because autoprovisionig features are freely available.

    But I'd like to know why "my" method is never called in 8.x

    TIA,
    Antonio

  4. #4
    Jignesh is offline Senior Member
    Join Date
    Oct 2011
    Location
    jignesh_22_1990@yahoo.com
    Posts
    68
    Rep Power
    3

    Default

    public static Account getCurrentAccount(HttpServletRequest r)
    throws AuthTokenException, ServiceException {
    Options opts = new Options();
    opts.setLocalConfigAuth(true);
    SoapProvisioning sp = new SoapProvisioning(opts);
    return sp.get(AccountBy.id, AuthToken.getAuthToken(getAuthToken(r)).getAccount Id();
    }

    If you need account object in z8 then this is the code.

  5. #5
    amessina's Avatar
    amessina is offline Active Member
    Join Date
    Jun 2007
    Location
    Campobello di Mazara, Italy
    Posts
    38
    Rep Power
    7

    Default

    Quote Originally Posted by Jignesh View Post
    public static Account getCurrentAccount(HttpServletRequest r)
    throws AuthTokenException, ServiceException {
    Options opts = new Options();
    opts.setLocalConfigAuth(true);
    SoapProvisioning sp = new SoapProvisioning(opts);
    return sp.get(AccountBy.id, AuthToken.getAuthToken(getAuthToken(r)).getAccount Id();
    }

    If you need account object in z8 then this is the code.
    Your code works for sure for GetAccount/SOAP for admin requests, not for AuthRequest/SOAP ones: you know they are different circumstances!

    As I said in another thread, when a user tries to login the account existence is verified BEFORE the real auth phase. This is handled by the com.zimbra.cs.service.account.Auth handler, registered by com.zimbra.cs.service.account.AccountService, and that is the reason why the Auth class has been improved in z8 to start the user autoprovision.

    Because I haven't found a (clean) way to register a MyAuth handler with a code like dispatcher.registerHandler(AccountConstants.AUTH_R EQUEST, new myAuth()), I thought of a different approach.

    Look at this default value:
    Code:
    [zimbra@zimbra8 ~]$ zmlocalconfig -d | grep zimbra_class_provisioning
    zimbra_class_provisioning = com.zimbra.cs.account.ldap.LdapProvisioning
    If I extend the com.zimbra.cs.account.ldap.LdapProvisioning class and assign the new one to zimbra_class_provisioning then I think that the new one should be called.

    As a matter of fact, this works great in z7. Why not in z8?

    Halfway, indeed: object instantiated (the constructor prints to log) but get() method never called. It drives me crazy!

  6. #6
    amessina's Avatar
    amessina is offline Active Member
    Join Date
    Jun 2007
    Location
    Campobello di Mazara, Italy
    Posts
    38
    Rep Power
    7

    Default It works

    Quote Originally Posted by yutaka View Post
    When you send AuthRequest/SOAP, "get(AccountBy keyType, String key, boolean loadFromMaster)" is called
    get(AccountBy keyType, String key) is called instead, and then it calls implicitly get(keyType, key, false).

    Overriding the first method does the job in z8 too.

    Thank you all
    Antonio

  7. #7
    amessina's Avatar
    amessina is offline Active Member
    Join Date
    Jun 2007
    Location
    Campobello di Mazara, Italy
    Posts
    38
    Rep Power
    7

    Default AccountBy

    The same code can't work both in z7 and in z8 due to the different declaration of AccountBy:


    • z7: com.zimbra.cs.account.Provisioning.AccountBy


    • z8: com.zimbra.common.account.Key.AccountBy



Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. (How to) write zimlet for extending LDAP objects?
    By DRVTiny in forum Developers
    Replies: 1
    Last Post: 01-01-2011, 08:52 AM
  2. Extending LDAP database
    By frost983 in forum Developers
    Replies: 3
    Last Post: 11-02-2010, 06:46 AM
  3. Extending Zimbra LDAP schema
    By TomL in forum Administrators
    Replies: 1
    Last Post: 02-02-2010, 06:04 AM
  4. Extending Zimbra
    By JoshuaPrismon in forum Developers
    Replies: 1
    Last Post: 06-20-2009, 07:12 AM
  5. Extending external LDAP -> GAL setup in UI
    By ab5602 in forum Developers
    Replies: 1
    Last Post: 12-17-2007, 12:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •