Sure, they can get DNA from anything from the child, but it wouldn't hold up in court if it was taken illegally.
If they took it from the trash that was thrown out would it be illegal?