I am now working on C# with WebDAV on Exchange now to get appointments. When I work local on the domain where the server is, i can get the appointments no problem. When I work outside of it, i get an SecurityException. This is my code to get the appointments:
protected void getAfspraken()
{
NetworkCredential credential = new NetworkCredential("bhees","1234567", "oaicttest");
WebdavSession session = new WebdavSession(credential);
session.UserMailbox = "http://192.168.0.56/exchange/bhees/";
Resource resource = new Resource(session);
//retreive single appointment
//Appointment appointment1 = resource.GetAppointment("http://myserver/exchange/Administrator/Calendar/appointment1.eml");
//retrieve all appointments from Calendar folder
Appointment[] allAppointments = resource.GetAppointments();
//retrieve all appointments from specified folder
//Appointment[] testAppointments = resource.GetAppointments("http://myserver/exchange/bhees/Calendar/Test");
//retrieve all appointments from specified public folder
//Appointment[] publicAppointments = resource.GetAppointments("http://myserver/public/Calendar");
Response.Write(allAppointments.ToString());
}
I get following errors:
Regel 98:
Regel 99: //retrieve all appointments from Calendar folder
Regel 100: Appointment[] allAppointments = resource.GetAppointments();
Regel 101:
Regel 102: //retrieve all appointments from specified folder
Bronbestand: \\fs11\ao-ict\UserData\ahoeve\Mijn documenten\Visual Studio 2005\WebSites\WebSite2\Default.aspx.cs Regel: 100
Stacktracering:
[SecurityException: De aanvraag voor machtiging van type System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 is mislukt.]
System.Security.CodeAccessSecurityEngine.Check(Obj ect demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
System.Security.CodeAccessPermission.Demand() +59
System.Net.HttpWebRequest..ctor(Uri uri, ServicePoint servicePoint) +166
System.Net.HttpRequestCreator.Create(Uri Uri) +26
System.Net.WebRequest.Create(Uri requestUri, Boolean useUriBase) +373
System.Net.WebRequest.Create(String requestUriString) +81
Independentsoft.Webdav.Exchange.Resource.r(String A_0) +786
Independentsoft.Webdav.Exchange.Resource.c(String A_0, String A_1) +60
Independentsoft.Webdav.Exchange.Resource.a(String A_0, PropertyName[] A_1) +1593
Independentsoft.Webdav.Exchange.Resource.GetProper ties(String address, PropertyName[] propertyName) +34
Independentsoft.Webdav.Exchange.Resource.d(String A_0) +992
Independentsoft.Webdav.Exchange.Resource.GetMailbo x(String userMailboxAddress) +30
Independentsoft.Webdav.Exchange.Resource.get_Mailb ox() +176
Independentsoft.Webdav.Exchange.Resource.GetAppoin tments(Boolean recursive) +31
Independentsoft.Webdav.Exchange.Resource.GetAppoin tments() +27
_Default.getAfspraken() in \\fs11\ao-ict\UserData\ahoeve\Mijn documenten\Visual Studio 2005\WebSites\WebSite2\Default.aspx.cs:100
_Default.DropDownList1_SelectedIndexChanged(Object sender, EventArgs e) in \\fs11\ao-ict\UserData\ahoeve\Mijn documenten\Visual Studio 2005\WebSites\WebSite2\Default.aspx.cs:114
System.Web.UI.WebControls.ListControl.OnSelectedIn dexChanged(EventArgs e) +105
System.Web.UI.WebControls.DropDownList.RaisePostDa taChangedEvent() +134
System.Web.UI.WebControls.DropDownList.System.Web. UI.IPostBackDataHandler.RaisePostDataChangedEvent( ) +7
System.Web.UI.Page.RaiseChangedEvents() +137
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6953
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +154
System.Web.UI.Page.ProcessRequest() +86
System.Web.UI.Page.ProcessRequestWithNoAssert(Http Context context) +18
System.Web.UI.Page.ProcessRequest(HttpContext context) +49
ASP.default_aspx.ProcessRequest(HttpContext context) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temp orary ASP.NET Files\website2\10a0ed41\15fb0a6\App_Web_kciwksky.2 .cs:0
System.Web.CallHandlerExecutionStep.System.Web.Htt pApplication.IExecutionStep.Execute() +154
System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean& completedSynchronously) +64
Can someone please help me?