04 December 2010

The request failed with HTTP status 401: Unauthorized

ב- SharePoint , ובכלל ב- asp.net אשר אני פונה לשרת נוסף ואני עובד ב-NTLM  ולא ב- Kerberos, אני אמור להעביר Credential. הבעיה מתחילה, כאשר הזמן לא מספיק, ואז מקבלים שגיאה, שבכלל אומרת שאין לי הרשאות לשרת, למרות שהעברתי את ה Credential.

The request failed with HTTP status 401: Unauthorized

יש שני פתרונות קלים:
האחד, להוסיף זמן ב- Web.Config - Timeout
השני והנכון יותר (לפי דעתי), זה לפנות בThread-  נוסף לשרת המרוחק.
הנה דוגמה לקוד שפונה ב- Thread נוסף. שימו לב, שהגדרתי DefaultCredentials לפני פתיחת ה- Thread.

WSrv.MyService wsrv = new MyService();
wsrv.Credentials = CredentialCache.DefaultCredentials;
System.Threading.Thread t = new System.Threading.Thread(delegate()
{
   resp = wsrv.CallMyWebService(prms);
});
t.Start();
t.Join();

לא מסובך, ועובד.
חג שמח,
רועי ק.

1 comment:

Roi kolbinger said...

see the post in english:
http://iwillsharemypoint.blogspot.com/2011/04/ntlm-problam-request-failed-with-http.html

Post a Comment