In Magento, when trying to generate a link from the front end to edit a customer, the link I generate is always redirecting me back to the dashboard of the admin area even though it looks correct.
I've tried it on multiple versions of Magento (and on both community and Enterprise), with the same result.
$adminUrl = Mage::helper('adminhtml')->getUrl('adminhtml/customer/edit/index',array('id'=>7));
$adminUrl2 = Mage::helper("adminhtml")->getUrl("adminhtml/customer/edit/id/".'7'."/");
This produces a url such as: /admin/customer/edit/id/7/key/f126e6cd7af2eb8cd068ff80fb512d4a/
Which appears to be right, but when it's clicked it sends me back to the dashboard of the admin area.
However, the following code works and does not redirect me to the dashboard:
$adminUrl = Mage::helper('adminhtml')->getUrl('adminhtml/catalog_product/edit', array('id' => 157990));
If I manually copy the url minus the key, and replace the key with a key that was generated by navigating through the admin area (i.e. by copying a working key from the navigation bar in my browser), it works - so I'm thinking it must be related to that somehow.
When you generate an admin URL from the frontend, Magento uses the form key from the frontend session. Then, when you click that link, Magento regenerates the admin URL key to compare against the key in the link, only this time, it uses the adminhtml form key. Since the form keys don't match, the hashed URL key doesn't match, and your link will not work. Magento's behavior at this point is to kick you back to the admin dashboard (or to the admin login page).
Any controller that inherits from Mage_Adminhtml_Controller_Action can allow certain actions to not require a admin URL key by adding them to the $_publicActions array.
For example, add into Mage_Adminhtml_CustomerController
public $_publicActions = array('edit');