Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 14th, 2007, 05:04 AM
Registered User
 
Join Date: Mar 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default C# Exchange

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?


 
Old March 14th, 2007, 07:01 AM
Authorized User
 
Join Date: Dec 2006
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Sunnys Send a message via Yahoo to Sunnys
Default

hi
  this exception come due to the trust level set to default "Medium" in the machine.config file of server.
this link will help u
http://msdn.microsoft.com/library/de...aght000020.asp

 
Old March 15th, 2007, 03:39 AM
Registered User
 
Join Date: Mar 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I've now set the trust to full, and i am still getting the same error. Does anyone has another solution for me?







Similar Threads
Thread Thread Starter Forum Replies Last Post
C# Exchange arjen1984 C# 1 March 5th, 2007 08:41 AM
Exchange + mail DuhMaster ASP.NET 2.0 Professional 0 December 20th, 2006 04:47 AM
Exchange DuhMaster ASP.NET 2.0 Basics 0 December 20th, 2006 04:21 AM
Link to Exchange jfleming SQL Server 2000 3 January 3rd, 2005 09:40 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.