The RealName module allows the administrator to choose fields from the user profile that will be used to add a "real name" element (method) to a user object. Hook_user is used to automatically add this to any user object that is loaded. It will also optionally set all nodes and comments to show this name.
The module underwent a major rewrite and simplification for Drupal 7 and now depends on the core token API and the Token module for its functionality. See http://drupal.org/node/1068734 for more information about the changes.
Drupal 7 core also now provides a central function that should be used to output a user's name: format_username() thanks to issue which was accepted into Drupal 7.
The 6.x version of this module supports both the core Profile module and the contributed Content Profile module, and can be extended to other profile providers. Check the documentation page for more information.