2011-04-26 2 views
1

안녕하세요. 저는 모든 Sharepoint yimmer yammer가 설치된 IIS 7 서버에서 클래스를 실행하고 있습니다. MSDN 사이트에서 연습을 통해 만든 webservice가 있습니다.RunWithElevatedPrivileges가 내 로깅을 숨기려하는 것 같습니다.

내 LINQ 클래스를 작동 시키려면 ElevatedPrivilleges 호출을 사용해야한다는 것을 알았습니다.

일단 내가 한 경우 NLog 기반 로거가 NLog 문서에서 말한 것처럼 web.config 파일과 동일한 디렉토리에있는 web.nlog 파일을 찾을 수 없게되는 것 같습니다.

위임자 외부의 모든 로그 문은 정상적으로 작동하며 내부의 모든 로그 파일은 절대 로그 아웃되지 않습니다.

그 대리인이 실제로 무엇을하고 있는지 알려주시겠습니까?

높은 특별인가 위양이 웹 애플리케이션 계정으로 그 안에 코드를 실행합니다
using System; 
using System.Web.Services; 
using Notification.DAL; 
using SharePointConnector; 
using NLog; 
using Microsoft.SharePoint; 

namespace NotificationReceiverService 
{ 

    [WebService(Namespace = "http://midwestiso.org/")] 
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] 
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService] 

    public class Service : System.Web.Services.WebService 
    { 
     private static Logger logger = LogManager.GetCurrentClassLogger(); 
     private static readonly String MACHINE_NAME = Environment.MachineName.ToUpper(); 

     public Service() 
     { 
      //Uncomment the following line if using designed components 
      //InitializeComponent(); 
     } 

     [WebMethod] 
     public string HelloWorld() 
     { 
      return "Hello World, You've contacted the Notifications Receiver Service. " + 
       "Please refer to the WSDL for the other available methods"; 
     } 

     [WebMethod] 
     public string EchoMessage(string MESSAGE_TEMPLATE_NAME, string MESSAGE_SUBJECT, string MESSAGE_TEXT_SUMMARY, 
            string MESSAGE_TEXT_DETAIL, string MESSAGE_TEXT_CON_OPS) 
     { 
      return String.Format("You called EchoMessage and told me {0}, {1}, {2}, {3}, {4}", 
       MESSAGE_TEMPLATE_NAME, MESSAGE_SUBJECT, MESSAGE_TEXT_SUMMARY, MESSAGE_TEXT_DETAIL, MESSAGE_TEXT_CON_OPS); 
     } 

     [WebMethod] 
     public string SendMessage(string MESSAGE_TEMPLATE_NAME, string MESSAGE_SUBJECT, string MESSAGE_TEXT_SUMMARY, 
            string MESSAGE_TEXT_DETAIL, string MESSAGE_TEXT_CON_OPS) 
     { 
      logger.Info("------" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Name + " starting on " + MACHINE_NAME + "------"); 
      try 
      { 
       //SPSecurity.RunWithElevatedPrivileges(delegate 
       // { 
        int? newNotificationId = 0; 
        using (var db = new MISO_IR_IntegrationDataContext()) 
        { 
         logger.Error("Message Received is: {0} - {1} - {2} - {3} - {4} - {5}", 
         DateTime.UtcNow.AddHours(-5), MESSAGE_TEMPLATE_NAME.Trim(), 
          MESSAGE_SUBJECT.Trim(), MESSAGE_TEXT_SUMMARY.Trim(), 
          MESSAGE_TEXT_DETAIL.Trim(), MESSAGE_TEXT_CON_OPS.Trim()); 

         int dbProcReturnCode = db.InsertReceivedNotification(DateTime.UtcNow.AddHours(-5), 
          MESSAGE_TEMPLATE_NAME.Trim(), MESSAGE_SUBJECT.Trim(), MESSAGE_TEXT_SUMMARY.Trim(), 
          MESSAGE_TEXT_DETAIL.Trim(), MESSAGE_TEXT_CON_OPS.Trim(), ref newNotificationId); 

         if (dbProcReturnCode == 0) 
         { 
          logger.Info("Notification saved to DB with ID: {0}", newNotificationId); 
          logger.Debug("Getting read to call CreatePublishingPagefromNotification"); 
         // PagePublisher.CreatePublishingPagefromNotification((int)newNotificationId); 
          logger.Debug("Complete calling CreatePublishingPagefromNotification without exception"); 
         } 
         else 
         { 
          throw new Exception("Unable to find mapping for this MESSAGE_TEMPLATE, saved the message to the notification table with ERRORNOMAPPING code, aborting further processing"); 
         } 
        } 
       // }); 
      } 
      catch (Exception ex) 
      { 
       logger.ErrorException(ex.Message, ex); 
       return "ERRORPOOP"; 
      } 
      finally 
      { 
       logger.Info("------" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Name + " COMPLETED ------"); 
      } 
      return "OK"; 
     } 
    } 
} 
+0

거기에 코드가 누락되었다고 생각합니다. 그것은 의미가 없습니다. –

+0

그래, 코드가 꽤 길어. 방금 몇 가지 기준을 제시해 줬어. –

+0

가능한 경우 게시하십시오. 있는 그대로, 나는 그것이 작동하지 않을 것이라는 것을 전혀 몰랐고, 나머지 코드를 보는 것이 도움이 될 수 있습니다. –

답변

0

은 (즉, 코드는 더 이상 코드를 실행하는 사용자를 가장하지 않음).

웹 응용 프로그램이 실행중인 계정을 확인한 다음 사용자와 함께 로깅 메시지가 변경되는 이유를 파악하십시오.

관련 문제