When can a connection Induce a Riemannian metric for which it is the Levi-Civita connection? As we all know, for a Riemannian manifold $(M,g)$, there exists a unique torsion-free connection $\nabla_g$, the Levi-Civita connection, that is compatible with the metric.
I was wondering if one can reverse this situation: Given a manifold with $M$ with connection $\nabla$, when does there exist a Riemannian metric $g$ for which $\nabla$ is the Levi-Civita connection.
If this were true for complex projective manifolds it would make me be very happy.
 A: This question has been definitively answered in the following paper:
http://nzjm.math.auckland.ac.nz/images/f/f4/When_is_a_Connection_Metric_Connection%3F.pdf
A: Bill and Willie have (of course) given correct answers in terms of the holonomy of the given torsion-free connection $\nabla$ on the $n$-manifold $M$.  However, it should be pointed out that, practically, it is almost impossible to compute the holonomy of $\nabla$ directly, since this would require integrating the ODE that define parallel transport with respect to $\nabla$.  Even though they are linear ODE, for most connections given explicitly by some functions $\Gamma^i_{jk}$ on a domain, one cannot perform their integration.
Although, as Bill pointed out, you cannot always tell from local considerations whether $\nabla$ is a metric connection, you can still get a lot of information locally, and this usually suffices to determine the only possibilities for $g$.  The practical tests (carried out essentially by differentiation alone) were of great interest to the early differential geometers, but they don't get much mention in the modern literature.
For example, one should start by computing the curvature $R$ of $\nabla$, which is a section of the bundle  $T\otimes T^\ast\otimes \Lambda^2(T^\ast)$.  (To save typing, I won't write the $M$ for the manifold.)  
Taking the trace (i.e., contraction) on the first two factors, one gets the $2$-form $tr(R)$.  This must vanish identically, or else there cannot be any solutions of $\nabla g = 0$ for which $g$ is nondegenerate.  (Geometrically, $\nabla$ induces a connection on $\Lambda^n(T^\ast)$ (i.e., the volume forms on $M$) and $tr(R)$ is the curvature of this connection.  If this connection is not flat, then $\nabla$ doesn't have any parallel volume forms, even locally, and hence cannot have any parallel metrics.)  
To get more stringent conditions, one should treat $g$ as an unknown section of the bundle $S^2(T^\ast)$, pair it with $R$ (i.e., 'lower an index') and symmetrize in the first two factors, giving a bilinear pairing $\langle g, R\rangle$ that is a section of $S^2(T^\ast)\otimes \Lambda^2(T^\ast)$.  By the Bianchi identities, the equation $\langle g, R\rangle = 0$ must be satisfied by any solution of $\nabla g = 0$.  Notice that these are linear equations on the coefficients of $g$.  For most $\nabla$ when $n>2$, this is a highly overdetermined system that has no nonzero solutions and you are done.  Even when $n=2$, this is usually $3$ independent equations for $3$ unknowns, and there is no non-zero solution.
Often, though, the equations $\langle g, R\rangle = 0$ define a subbundle (at least on a dense open set) of $S^2(T^\ast)$ of which all the solutions of $\nabla g= 0$ must be sections.  (As long as $R$ is nonzero, this is a proper subbundle.  Of course, when $R=0$, the connection is flat, and the sheaf of solutions of $\nabla g = 0$ has stalks of dimension $n(n{+}1)/2$.)  The equations $\nabla g = 0$ for $g$ a section of this subbundle are then overdetermined, and one can proceed to differentiate them and derive further conditions.  In practice, when there is a $\nabla$-compatible metric at all, this process spins down rather rapidly to a line bundle of which $g$ must be a section, and one can then compute the only possible $g$ explicitly if one can take a primitive of a closed $1$-form.
For example, take the case $n=2$, and assume that $tr(R)\equiv0$ but that $R$ is nonvanishing on some simply-connected open set $U\subset M$.  In this case, the equations $\langle g, R\rangle = 0$ have constant rank $2$ over $U$ and hence define a line bundle $L\subset S^*(T^\ast U)$.  If $L$ doesn't lie in the cone of definite quadratic forms, then there is no $\nabla$-compatible metric on $U$.  Suppose, though, that $L$ has a positive definite section $g_0$ on $U$.  Then there will be a positive function $f$ on $U$, unique up to constant multiples, so that the volume form of $g = f\ g_0$ is $\nabla$-parallel.  (And $f$ can be found by solving an equation of the form $d(\log f) = \phi$, where $\phi$ is a closed $1$-form on $U$ computable explicitly from $\nabla$ and $g_0$.  This is the only integration required, and even this integration can be avoided if all you want to do is test whether $g$ exists, rather than finding it explicitly.)  If this $g$ doesn't satisfy $\nabla g = 0$, then there is no $\nabla$-compatible metric.  If it does, you are done (at least on $U$).
The complications that Bill alludes to come from the cases in which the equations $\langle g, R\rangle = 0$ and/or their higher order consequences (such as $\langle g, \nabla R\rangle = 0$, etc.) don't have constant rank or you have some nontrivial $\pi_1$, so that the sheaf of solutions to $\nabla g = 0$ is either badly behaved locally or doesn't have global sections.  Of course, those are important, but, as a practical matter, when you are faced with determining whether a given $\nabla$ is a metric connection, they don't usually arise.
A: Yes.
First, there's a very simple criterion for whether $\nabla$ is an orthogonal connection:  look at the holonomy of $\nabla$ around closed 
loops in the manifold, and ask whether they preserve a quadratic form. The set of
quadratic forms preserved by a linear transformation is a linear subspace of all quadratic
forms, so there's some linear subspace of quadratic forms preserved by the holonomy.
The condition that $\nabla$ is torsion free doesn't depend on a metric, so it's straightforward to check.   The necessary and sufficient condition for $\nabla$
to be a Levi-Civita condition is that its holonomy preserve at least one positive definite
quadratic form, and that it be torsion-free.
Note that the condition on holonomy is global: it can't be reduced to some set of pointwise
identities involving
$\nabla$, or even the local behavior
of $\nabla$.  For instance, take $\nabla$ to be the standard flat connection in $\mathbb R^n \setminus 0$
modulo the  linear transformation $x \rightarrow 2x$.  Since $\nabla$ is preserved
by $x \rightarrow 2x$, it descends to the quotient $S^{n-1} \times \mathbb R$.  It can
locally be expressed as a Levi-Civita connection, but there is no globally-defined metric
for which it is the Levi-Civita connection. 
It's also possible to concoct simply-connected examples with a connection that
is locally Levi-Civita, but not globally Levi-Civita.  For instance:  inside $S^3$
embed a copy of $T^2 \times I$, and make a Riemannian metric that  for which $T^2 \times I$
is isometric to $[0,1] \times \mathbb E^2$ modulo a discrete group of translations,
and for which each component of the complement has holonomy (as usual)
 equal to the full $SO(3)$.  Make a second, similar metric, but where the $T^2$ has
a different shape.  Make a hybrid of the two, combining half from one $S^3$ and the 
other half
from the other $S^3$, glued together by an affine map of the torus. The flat
connection is identified by the  gluing map, but the holonomy does not globally
preserve a Riemannian metric.
A: For a connection with "full rank" curvature matrix I think I have a more complete answer in form of an algorithm that verifies whether the connection is metric. This is partly based on an observation made by Robert Bryant so at least that part is 100% correct.    
Consider  a connection $D$ in the vector bundle $E.$ We assume that the curvature matrix has " full rank"(I can elaborate on this condition on the curvature) on a open set $U.$ We'd like to verify if the connection is metric on $U.$  
We have the following steps in deciding weather the connection $D$ is metric on $U$:
1.Take a local frame $\sigma=(\sigma_1, \sigma_2,...,\sigma_m )$ on $U$ and calculate the curvature matrix $\Omega$ with respect to this frame.


*Determine the matrices $S_{ij}$(with real smooth functions as entries) defined by the equation 
$$ 
\Omega=\sum_{i<j} (\sigma^i \wedge \sigma^j)  S_{ij} .$$

*Form the linear system $$ XS_{ij}+S_{ij}^TX=0. $$

*If the linear system from the previous step doesn't have a symmetric, positive definite solution $X=A$, the $D$ is not metric.

*If the solution $X=A$ exists then take its square root $\sqrt{A}=B$.

*Form the frame $\sigma'$ defined by $$\sigma'=\sigma B$$ and test whether the connection forms with respect to $\sigma'$ are skew. If they are not then the connection is not metric on $U$.

*If the connection forms with respect to $\sigma$ are skew, then the metric that makes $\sigma$ orthonormal is compatible with the connection.
A: To start with, you need the connection to be torsion free. After that, there is a characterisation of metric connections given by Schmidt, CMP 29 (1973) 55-59, which states that the linear torsion-free connection is metric if and only if the holonomy group is a sub-group of the orthogonal group of the desired signature.
A: Since my previous answer only applies to local existence of a metric compatible to a given connection I'd like to address the global problem as well. A possible obstruction for the global metrizability of a connection in any vector bundle is obtained by calculating the Euler class of the connection. The Euler class of any locally metric connection is well defined via the Pfaffian of its curvature matrix. If its Euler class doesn't equal the Euler characteristic of the manifold then the connection cannot be globally metric. I believe that calculating the Euler class of the connection is much simpler than calculating its holonomy group.
