how to get the projection from a vectorlayer in qgis?

Short answer

qgis.utils.iface.activeLayer().crs().authid()
# returns: PyQt4.QtCore.QString(u'EPSG:26913')

Explanation

qgis.utils.iface.activeLayer() returns a reference to the active QgsMapLayer.

QgsMapLayer.crs() returns the crs or QgsCoordinateReferenceSystem for the layer.

QgsCoordinateReferenceSystem.authid() returns the Authority identifier for the crs as a QString.

However, this is assuming there is an active layer, it is of a vector type, and it has a valid crs. You will want to test for validity of those items before committing to reprojecting a raster.

If you are reprojecting, using GDAL.Dataset.SetProjection() will not suffice, since it will only assign a projection and not reproject (warp) the raster to the same as your vector layer.