It depends on the user's settings.
https://www.linkedin.com/help/linkedin/answer/1584 says InMail allows you to directly message another LinkedIn member that you're not connected to.
Note: If you have a Basic (free) account, you can only directly message LinkedIn members that you’re connected to. You must upgrade to a Premium account to use InMail