Short answer: you can't retrieve it. "Team Fortress 2" is the default name a server receives when its owner never set a custom one, so seeing that name tells you nothing about who runs the box or what they chose for a password.
When a server is locked, the owner has deliberately restricted it — usually to friends, a clan, or a community. The password lives with them, and Valve has no way to hand it to you. Trying to guess or bypass it will just get you kicked, and repeated attempts can get you banned outright.
Browse the public server list and join one with a ping and player count that suit you. Plenty of well-run public servers are open to anyone. If you were invited by a friend, just ask them for the password directly — that is the only legitimate route in.