Electromagnetic pinning of vortices on different types of defects