ua = A0  +  A1 x;  eq1 = u1 - ua /. x -> x1;  
    eq2 = u2 - ua /. x -> x2;
ua = 
      ua /. Solve[{eq1, eq2} == 0, {A0, 
              A1}][[1]]
  
cf = Factor[Coefficient[ua, {u1, u2}]]
cf /. {x1 -> 0, x2 -> L}

ua = A0  +  A1 x + A2 x^2;  eq1 = u1 - ua /. x -> x1;  
    eq2 = u2 - ua /. x -> x2;  
    eq3 = u3 - ua /. x -> x3;
ua = 
      ua /. Solve[{eq1, eq2, eq3} == 0, {A0, A1, 
              A2}][[1]]
  
Factor[Coefficient[ua, {u1, u2, u3}]]

ua = A0  +  A1 x + A2 x^2 + A3 x^3;  
    eq1 = u1 - ua /. x -> x1;  eq2 = u2 - ua /. x -> x2;  
    eq3 = u3 - ua /. x -> x3;  
    eq4 = u4 - ua /. x -> x4;
ua = 
        ua /. Solve[{eq1, eq2, eq3, eq4} == 0, {A0, A1, A2, 
                A3}][[1]];
  
Factor[Coefficient[ua, {u1, u2, u3, u4}]]