The overall plan is fine. The possible issue is AC vs. DC. IF both the adapter and the solenoid are rated for 12 VAC, then you should be ok. Note that with AC there is no power polarity at the load. In the photo it shows the power supply and solenoid with red and black wires. If your actual components are like this, it is *not* important that red goes to red and black to black.
Most of what people call an "AC adapter" in fact have a DC output, so check this carefully. If you post links to your actual parts, we can review them. Photos also work. The adapter will have either a label or a molded section with text. Photo that. The solenoid might have a similar label or stamping.
ak