SOAP pour authentification Zimbra - auth failed
Bonjour à tous,
Je travaille actuellement sur un service en C# .net à me connecter a un serveur zimbra en utilisant le protocole SOAP.
J'arrive a me connecter en utilisant le mot de passe, mais dès que je veux utiliser une clé de pre-auth (obtenue à partir du serveur Zimbra), je n'obtiens qu'une authentification failed.
Voici le message SOAP:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
DateTime d1 = new DateTime(1970, 1, 1);
DateTime d2 = DateTime.Now;
TimeSpan ts = new TimeSpan(d2.Ticks - d1.Ticks);
//correct .net timezone
TimeSpan utcOffset = TimeZone.CurrentTimeZone.GetUtcOffset(d2);
Int64 tsint = (long)ts.TotalMilliseconds - (long)utcOffset.TotalMilliseconds;
timestamp = tsint.ToString();
ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, errors) => true;
StringBuilder sbXML2 = new StringBuilder();
sbXML2.Append("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");
sbXML2.Append("<soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\">");
sbXML2.Append("<soap:Header>");
sbXML2.Append("<context xmlns=\"urn:zimbra\">");
sbXML2.Append("<format type=\"xml\"/>");
sbXML2.Append("</context>");
sbXML2.Append("</soap:Header>");
sbXML2.Append("<soap:Body>");
sbXML2.Append("<AuthRequest xmlns=\"urn:zimbraAccount\">");
sbXML2.Append(string.Format("<account>{0}</account>", userId));
sbXML2.Append(string.Format("<preauth timestamp =\"{0}\" expires=\"0\">{1}</preauth>", timestamp,pwd));
sbXML2.Append("</AuthRequest>");
sbXML2.Append("</soap:Body>");
sbXML2.Append("</soap:Envelope>"); |
Merci d'avance pour votre aide.
@+