The solenoid and the bar magnet generate their magnetic fields using different mechanisms, so the solenoid equation cannot be applied to a bar magnet.
A moving charge, like an electron, generates a magnetic field, and a current is just a load of charges moving in a conductor. That's why a current generates a magnetic field. The equation for the solenoid is derived using Ampère's law for the specific geometry of a solenoid and feeding in the current in the wire.
However even a stationary electron has a (tiny) magnetic field due to its spin. This field is always present whether or not the electron is moving. This is called its magnetic moment. In most cases the electrons have their fields arranged randomly so their fields cancel out and the total magnetic field is zero. However in a class of materials known as ferromagnets the electron fields
line up with each other to generate a large total field, and that's what happens in a bar magnet. Since this field has nothing to do with currents you cannot use Ampère's law to calculate it.