Ruby, 113 112 105 98 97 95 87 bytes
I sort of double-posted my Python answer (somehow), so here's a Ruby answer. Seven more bytes thanks to manatworkmanatwork, another byte thanks to Martin BüttnerMartin Büttner, and 8 more bytes thanks to cia_ranacia_rana.
->n,f,t,d{z=0;s='';n.chars{|i|z=z*f+d.index(i)};(s=d[z%t]+s;z/=t)while z>0;s[0]?s:d[0]}
Ungolfed:
def a(n,f,t,d)
z=0
s=''
n.chars do |i|
z = z*f + d.index(i)
end
while z>0
s = d[z%t] + s
z /= t
end
if s[0] # if n not zero
return s
else
return d[0]
end
end