Rules on photography depends on the place. Many mosques will allow photography inside and outside. Some museums will not allow photography inside but will outside.
Photography in public
For people, when taking photos of specific people, it is always better to ask for permission. Often this will led to a positive response, many Iranians like to pose for photos.
Generally, if it is not permitted, a sign will indicate. Restrictions are placed on photography of government and military buildings.