+ Start a Discussion
earlbarbyearlbarby 

License enforcement with the LMA for globally exposed APEX classes

Hi. We have a managed package and we use the LMA for customer installations. We are considering exposing portions of the APEX globally to allow customers to clone the Visualforce pages in our package and then customize layout, fields, etc. However, we made a quick test package and it appears that the LMA does not enforce access to APEX classes that are global. Is this correct? Is there any way to enforce licenses in this case?

A_SmithA_Smith

Licensing should be enforced on global apex.  If the apex is called from other apex, then likely the licensing enforcement won't occur unless the package license has expired (doesn't matter if the individual user has a license since apex runs as system).  

earlbarbyearlbarby

Thanks for the response, Andrew. If I'm reading you correctly then user licenses will not be enforced on global apex, correct? As an example scenario for us, suppose that a customer with 50 users in their organization buys 10 user licenses of our product. We want to use global classes to allow the customer to customize Visualforce pages for the 10 licensed users, but not allow the other 40 users access to our package. Is this possible?

A_SmithA_Smith

This is covered.  A user loading the VF page using your controller must have a license to see the page.  

earlbarbyearlbarby

That doesn't appear to be the case. I tried that situation with some test orgs. I created a new dummy managed package with a basic VF page and global apex controller, added it to the LMA, and then installed it into another org with a license for a single user. Without assigning any licenses, no users in that org can access the packaged VF page, which is expected. However, if I clone the packaged VF page (a simple copy&paste) then all users can access the cloned page, effectively overcoming the licensing entirely.

ca_peterson_oldca_peterson_old

I guess you can put a if(!UserInfo.isCurrentUserLicensed(namespace)) {System.assert(false);} statement in your page constructors to prevent unlicensed users from calling them, but that seems like something the system should be doing automatically.

earlbarbyearlbarby

Hi, ca_peterson. Thanks for the reply. I wasn't aware of the isCurrentUserLicensed method. It definitely works, but it's bothersome to have manually check the licensing. I also would expect all this to be handled automatically, but at least you gave me something workable.