if you have a medical permit to do recreational marijuana, will you get in trouble if you obtain it from a dealer?
1) The laws vary significantly by state
2) So far as I know there are no permits to do "recreational" marijuana. There are only permits to take "medicinal" marijuana. Which in practical terms, means that producers are allotted a maximum number of patients for whom they are permitted to grow a specified number of plants, and permitted to sell a specified number of ounces per period of time. Where all the specified numbers vary by state.
3) The present legal situation is that the federal government does not recognize state laws allowing "medical" marijuana. There have been a number of cases where providers following local state laws have been arrested by federal agents.
4) I advise due diligence
Short answer: Depends on what you mean by "dealer." If you mean buy it from some random guy on the street, so far as I am aware the laws do not allow that. At least, what he is doing is certainly going to be considered illegal. Last I looked into this there was no shortage of state-licensed producers looking for clients, though they appear to charge much more than you'd probably pay the drug pusher at your local high school.
In any case, if you have a permit, in Michigan at least, you are permitted (from the point of view of the state) to grow your own, within mandated limits. Though I understand it takes many months to get the process underway, and the requirements generally state that it must be grown in locked, indoor facilities. Check your local laws.