During the events of the Star Trek: The Next Generation 2-parter, The Best of Both Worlds, Riker received a field promotion to Captain while Picard was assimilated. Does this mean that Riker should be considered a Captain of the Enterprise? Or, as it was a field promotion, and not a proper promotion, does this mean he should not be considered a legitimate equal to such greats as Kirk and Picard in the annals of history?
Is Riker an official captain of an Enterprise? I guess that depends on your definition of who is a captain of an Enterprise. Technically, yes, Riker held a temporary field commission of Captain. But if you're going to apply that, then I believe you must also include a number of the TOS characters as well, who all held the rank of captain within Starfleet, even though they didn't hold the center chair. At the very least, as I recall, Spock, McCoy, Scott, Uhura and Sulu were all captains while serving aboard the Enterprise A. And you have to include Christopher Pike, Decker and whatever the names were of the two captains of the Enterprise B and Enterprise C that appear in the tv show and movies. C'mon, if you know their names without looking them up, you really need to get out more.... :)
But when it comes down to it, there is a huge difference between technically being a captain of the Enterprise and who you think about when you think of the Captains of the Enterprise. That's really what it comes down too. Was Riker a captain? Sure, for a couple days. Do we think about Riker when we're thinking about Captains of the Enterprise? For 99.9999% of us: Not a chance.
Yes, Riker was captain of the Enterprise, for a short amount of time. This is because he was the commanding officer of the Enterprise (not just the ranking officer on board, but was in command of the ship itself).
BBlake's point about the fact that several officers whom held the rank of captain (Spock, McCoy, Scott, Uhura, and Sulu) weren't The Captain Of The Enterprise because they weren't the commanding officers (except in the case of Spock, who was a Captain of the Enterprise).
Please, check out the bottom of any person who was given command of an Enterprise on Memory-Alpha. There is a list of "Commanding officers of The starships Enterprise". And before someone points out it says Commanding officers and not captain, please check out Captain#Starfleet Captains on Memory Alpha, which states the following:
On starships, the term captain is also often used as a synonym to commanding officer. Proper naval parlance says that, even if a vessel is commanded by an officer whose rank is lower than captain, that officer is still able to be referred to as a captain while on the deck of their own vessel, no matter their literal commissioned rank.
Which means that yes, Riker was captain of the Enterprise.
Yes, William T. Riker was, for a brief time, the official captain of the U.S.S. Enterprise NCC-1701-D. His name would be included in the vessel's command history.
He was given a field promotion and control of the ship by Admiral Hanson during the events of The Best of Both Worlds, parts 1 and 2.
Whether Riker is a heavyweight in the sense of Kirk or Picard is up to history. We can all assume that Riker enjoyed a storied career after his stints on the Enterprise D and the Enterprise E — enough to make him an admiral in at least one timeline...
Background on meaning of usage of "Captain" (in order to clarify the sense(s) in which this response answers the question)
As has been discussed in other answers and comments on this question, there is more than one usage of the word "captain". Captain is, first and foremost, a naval rank, used by Starfleet. Someone may hold the official rank of captain with or without having a ship to his or her name. (There may be a period of time where a captain is not assigned to the command of a starship, for various reasons.) Captain is also used to address the person who has been "given the conn" by the officer most recently in charge of the ship (an officer who may or may not be the official captain of the vessel.)
As an in-universe example, Kirk might leave the Enterprise with an away party and leave the conn to Spock. It is then customary for anyone serving on ship to address Spock as "Captain" (even though Spock's official rank was "Commander" during the TOS years). This usage occurs especially in an affirmative to a direct order, i.e. answering "Yes, Captain" to whomever is in the Captain's chair. This usage of captain is customary, not official. Furthermore, it would be both awkward and incorrect for an officer to answer an order with "Yes, Captain Spock", as this would be inferred as an incorrect assessment of Spock's rank. In any case, if Spock were to then also join the away party, he may opt to leave the conn to Scott, who then is addressed as "Captain" by fellow officers (and so on).
In terms of Riker, he was left in charge of the bridge in many episodes, and therefore was "captain" in the customary sense on many occasions. However, Riker was captain in both the official and customary senses during The Best of Both Worlds. It was Starfleet's opinion that Picard (discovered to have been assimilated by the Borg and given the designation "Locutus") was irretrievable. Shortly before his death in the Battle of Wolf 359, Fleet Admiral Hanson bestowed upon Riker a field promotion to captain and gave him control of the Enterprise. It is safe to assume that Hanson had the command codes of the Enterprise formally transferred over to Riker, although this is not seen on-screen.
In Starfleet, field promotions are legitimate promotions regarding the career of active-duty officers. They are neither temporary nor honorific. Every Starfleet vessel has a "command history", indicating the individuals who were in possession of the vessel's command codes over its service life. Riker would be listed as the official captain, during the stardates of The Best of Both Worlds.
The command history of the Enterprise D, in chronological order:
Capt. Jean-Luc Picard
Capt. William Thomas Riker (during The Best of Both Worlds parts 1 and 2, then willingly and honorably downgraded to Commander upon Picard's return to active duty)
Capt. Jean-Luc Picard
Capt. Edward Jellico (during Chain of Command parts 1 and 2)
Capt. Jean-Luc Picard
Picard's captaincy of the Enterprise D ended when the ship was left unsalvageable during the film Generations.
Since Starfleet tends to follow US military traditions, let's look what they do. In the US military, by law, an officer not on active duty is allowed to be addressed by their highest rank achieved during wartime, even if it was a temporary commission.
(e) A person not on active duty who served honorably in time of war in the Army, Navy, Air Force, or Marine Corps may bear the title, and, when authorized by regulations prescribed by the President, wear the uniform, of the highest grade held by him during that war.
For example, George Custer is properly addressed as General Custer even though his permanent rank (and the one he held when he died) was Colonel. I think this speaks to the idea that temporary wartime commissions are considered serious business in the military.
Riker was given sole command of the Enterprise by Starfleet Command while having the rank of Captain, and he commanded the Enterprise in battle. This differentiates him from others who commanded the Enterprise in Picard's temporary absence. I think it would be fair to say Riker was a Captain of the Enterprise.
In Star Trek, field promotions are as valid as any promotion (even though Riker agreed to get demoted back to commander, a decision forced by the writers). Consider Wesley Crusher and Nog, both had field promotions and their ranks were valid.
In the final episode of TNG, "All Good Things", Admiral Riker shows up to save Captain Beverly Crusher from a Klingon attack. Admiral Riker is in command of the Enterprise and stated something about it being nice to keep hold of his old ship.
I guess that means he was a Captain of the Enterprise; in a different time line.
Garret was included in a list of Captains, but that two was an alternate timeline. Was she a Captain in the original TNG timeline?
And now, with the reset done in the last movie, is a timeline even a relevant factor when considering who was a Captain of the Enterprise?