I'm developing an Exchange Web Services Managed API client on top of ASP.NET MVC. Everything worked until we installed the latest Exchange CU update yesterday. Then I periodically got "target principal name is incorrect" errors after some time on my web server when connecting to EWS. These could get fixed temporarily by restarting the web server.
I then used this post to configure Kerberos correctly: Set up Kerberos Authentication with Delegation on IIS 7 w/ Windows Server 2008
Now I am stuck with the following error that I never had before:
Exception Details: System.Xml.XmlException: Root element is missing.
[XmlException: Root element is missing.]
System.Xml.XmlTextReaderImpl.Throw(Exception e) +88
System.Xml.XmlTextReaderImpl.ParseDocumentContent() +1383
System.Xml.XmlCharCheckingReader.Read() +153
Microsoft.Exchange.WebServices.Data.EwsXmlReader.Read() +63
Microsoft.Exchange.WebServices.Data.EwsXmlReader.Read(XmlNodeType nodeType) +44
Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ReadXmlDeclaration(EwsServiceXmlReader reader) +54
[ServiceRequestException: The response received from the service didn't contain valid XML.]
Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ReadXmlDeclaration(EwsServiceXmlReader reader) +165
Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ReadSoapFault(EwsServiceXmlReader reader) +43
Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ProcessWebException(WebException webException) +413
Microsoft.Exchange.WebServices.Data.ServiceRequestBase.GetEwsHttpWebResponse(IEwsHttpWebRequest request) +139
Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ValidateAndEmitRequest(IEwsHttpWebRequest& request) +573
Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest`1.Execute() +42
Microsoft.Exchange.WebServices.Data.ExchangeService.FindAppointments(FolderId parentFolderId, CalendarView calendarView) +104
Because this is a managed version of the Exchange Web Services API I have nothing to do with the XML Requests and Responses directly. It's basically a black box for me. As you can see from the error, it occurs when calling for data from EWS.
Related
First, for some context: I am using .NetCore to develop an API with Identity. Everything is on a Cloud server, inside a Docker. When a user is created, an email is sent to the new User using a mailkit and the webmail server through Plesk (Hosted on the same machine). The docker is accessed via a redirection trough Apache using a ProxyPass from the subdomain to the port on localhost
Everything works great while debugging trough JetBrain's Rider, but it is not able to process the email in the docker on the server.
Here is the stack:
System.Net.Internals.SocketExceptionFactory+ExtendedSocketException (00000001, 11): Resource temporarily unavailable
at System.Net.Dns.InternalGetHostByName(String hostName)
at System.Net.Dns.ResolveCallback(Object context)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(Exception source)
at System.Net.Dns.HostResolutionEndHelper(IAsyncResult asyncResult)
at System.Net.Dns.EndGetHostAddresses(IAsyncResult asyncResult)
at System.Net.Dns.<>c.<GetHostAddressesAsync>b__25_1(IAsyncResult asyncResult)
at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
I have yet to try and run the docker on another linux machine to test.
One of my current guess would be a problem with the SSL certificate, but I don't think it would cause a problem with the DNS or any internal socket.
Another guess is thats its a problem for the Docker to get the DNS Hostname, but since it works ok in a local.
Edit: I tried multiple time to run the docker on the mac and the error is still triggered once in a while but not always. It is although always triggered on the server and never send the email
After two weeks of research, I finally stumbled upon a solution for this:
The problem is related to the network, that was obvious, but it's precisely about how containers are isolated from one another. Problem is, the container has no outbound connection. A solution that work inside a standalone container is to use the --network host parameter, which would expose the host network to the container. Note that using this would remove the port mapping from the container since the container's port 5000 is now linked to the host's port 5000
Hope this solution can help others
I have a ASP.NET Web API Application which loads all the Groups which contains a Specific Name from Active Directory into internal Database.
This was working on Dev. PC (Windows 10), Testserver and old Productive Server (Windows Server 2012 R2)
But on the new Productive Server (Windows 2016) the same method ran into a Exception.
Illegal operation attempted on a registry key that has been marked for deletion.
Here the Code:
PrincipalContext ctx = new PrincipalContext(ContextType.Domain);
GroupPrincipal qbeGroup = new GroupPrincipal(ctx);
PrincipalSearcher srch = new PrincipalSearcher(qbeGroup);
var adGroups = srch.FindAll().Where(w => w.Name.Contains("_FS", StringComparison.InvariantCultureIgnoreCase));
var permissions = new List<PermissionGroup>();
// find all matches
foreach (var found in adGroups) {
var permission = new PermissionGroup(found.Name, found.Sid.ToString());
permissions.Add(permission);
}
Additional Information:
Windows Server 2016 Datacenter
Version 10.0.14393 Build 14393
Installed .NET Framework (Server 2016) .NET Framework 4.8
Used .NET Framework 7
Someone have an idea, what the problem can be?
Thanks
Added: 08.01.2020 16:11 (UTC +1)
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException:
Illegal operation attempted on a registry key that has been marked for
deletion.
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
Stack Trace:
[COMException (0x800703fa): Illegal operation attempted on a registry
key that has been marked for deletion. ]
System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) +535
System.DirectoryServices.DirectoryEntry.Bind() +48
System.DirectoryServices.DirectoryEntry.get_AdsObject() +43
System.DirectoryServices.PropertyValueCollection.PopulateList() +27
System.DirectoryServices.PropertyValueCollection..ctor(DirectoryEntry
entry, String propertyName) +122
System.DirectoryServices.PropertyCollection.get_Item(String
propertyName) +168
System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) +194
System.DirectoryServices.DirectoryEntry.Bind() +48
System.DirectoryServices.DirectoryEntry.get_AdsObject() +43
System.DirectoryServices.DirectorySearcher.FindAll(Boolean
findMoreThanOne) +91
System.DirectoryServices.DirectorySearcher.FindOne() +46
FragranceStudio.Webservice.Common.Helper.ActiveDirectoryHelper.SetADInformationToFragranceStudioPrincipal(FragranceStudioPrincipal
fragranceStudioPrincipal) in
C:\Repositories\VS2017\FragranceStudio\FragranceStudio\FragranceStudio.Webservice.Common\Helper\ActiveDirectoryHelper.cs:70
FragranceStudio.Webservice.Common.Security.ExtendedPermissionProvider.ReloadInheritedPermissionGroups(FragranceStudioPrincipal
principal) in
C:\Repositories\VS2017\FragranceStudio\FragranceStudio\FragranceStudio.Webservice.Common.Security\ExtendedPermissionProvider.cs:142
[FragranceStudioException: An unknown error has occurred. Please try
again or contact the Servicedesk.]
FragranceStudio.Webservice.Common.Security.ExtendedPermissionProvider.ReloadInheritedPermissionGroups(FragranceStudioPrincipal
principal) in
C:\Repositories\VS2017\FragranceStudio\FragranceStudio\FragranceStudio.Webservice.Common.Security\ExtendedPermissionProvider.cs:169
FragranceStudio.Webservice.Common.Security.ExtendedPermissionProvider.GetInheritedGroups(FragranceStudioPrincipal
principal) in
C:\Repositories\VS2017\FragranceStudio\FragranceStudio\FragranceStudio.Webservice.Common.Security\ExtendedPermissionProvider.cs:62
FragranceStudio.Webservice.Common.DomainEntities.Security.FragranceStudioPrincipal..ctor(IExtendedPermissionProvider
extendedPermissionProvider, WindowsPrincipal principal) in
C:\Repositories\VS2017\FragranceStudio\FragranceStudio\FragranceStudio.Webservice.Common\DomainEntities\Security\FragranceStudioPrincipal.cs:55
FragranceStudio.Webservice.WebApiApplication.Application_PostAuthenticateRequest(Object
sender, EventArgs e) in
C:\Repositories\VS2017\FragranceStudio\FragranceStudio\FragranceStudio.Webservice\Global.asax.cs:51
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+223 System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +220 System.Web.HttpApplication.ExecuteStep(IExecutionStep
step, Boolean& completedSynchronously) +94
Reading this article tells me that this issue is related to accessing the profile of the user. However, your app pool settings indicate that you're not even loading the user profile, which is likely the cause of your problem.
In your app pool settings, enable "Load User Profile".
This answer and the comment on this answer confirm that.
I'm not entirely sure why it throws this exception without turning that on, and why only with 2 worker processes. I'm curious about it too. It likely has something to do with what registry hives are given to the process when it's not the user's own registry hive, and that being closed when one worker process shuts down, preventing access to the other process. Just a guess there.
I found the issue, but i don't know why this happens.
On Maximum Worker Processes, was set to 2.
But why this is a problem for this the AD Query?
Autocomplete with jquery json with c#:
The program works on local but not works on server.Why?
[WebMethod]
public List<string> GetAutoCompleteData(string prefixText)
{
...
here is the error:
Internal server error 500
and also this error:
Server Error in '/' Application.
Unknown web method GetAutoCompleteData. Parameter name: methodName
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.ArgumentException: Unknown web method
GetAutoCompleteData. Parameter name: methodName
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
Stack Trace:
[ArgumentException: Unknown web method GetAutoCompleteData. Parameter
name: methodName]
System.Web.Script.Services.WebServiceData.GetMethodData(String
methodName) +539974
System.Web.Script.Services.RestHandler.CreateHandler(WebServiceData
webServiceData, String methodName) +10
System.Web.Script.Services.RestHandler.CreateHandler(HttpContext
context) +159
System.Web.Script.Services.RestHandlerFactory.GetHandler(HttpContext
context, String requestType, String url, String pathTranslated) +62
System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext
context, String requestType, String url, String pathTranslated) +47
System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execut
e()
+334 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184
Version Information: Microsoft .NET Framework Version:4.0.30319;
ASP.NET Version:4.0.30319.272
Ok, now we are getting somewhere.
If I understand this correctly, you have implemented a webmethod within your asp.net website in an asmx file (something that we are also doing in one of our products as well). In order for this to work properly in IIS (works fine in development environment), you will need to configure your IIS to allow .asmx pages (add a handler mapping). You can do this directly in the IIS config, or in your web.config.
Here is another question for reference:
ASMX service works on development server, returns 404 when deployed to IIS 7.5
Disregard bounty thing. Different question :)
Hi I am having some trouble accessing the Google Drive SDK, mainly the authentication steps.
I have two main pages in my .Net Web app - Default.aspx.cs and WebForm1.aspx.cs.
In Default.aspx I have a hyperlink control that takes the user to the Google authentication page when they click on the link:
https://accounts.google.com/o/oauth2/auth?response_type=code&scope=https://www.googleapis.com/auth/drive.file+https://www.googleapis.com/auth/userinfo.email+https://www.googleapis.com/auth/userinfo.profile&redirect_uri=http://localhost/GoogleDriveTest/GoogleDriveTest/GoogleDriveTest/WebForm1.aspx&state=/profile&client_id=*CLIENT_ID*&approval_prompt=force
Once the user is redirected back to the REDIRECT_URI (WebForm1), I use this piece of code to access the authorization code:
HttpRequestInfo request = new HttpRequestInfo(Request);
code = Request.QueryString["code"];
Now I am stuck. I know I need to now POST this code to:
https://accounts.google.com/o/oauth2/token <insert POST parameters here>
But I am completely stuck as to how to do this. I have tried many things, but all I am getting:
Server time out error - it failed to connect to the requested server
How do I resolve this issue?
EDIT 24/09/2012:
With the new release of Visual Studio 2012, they have incorporated OAuth so it takes care of authentication:
http://www.asp.net/vnext/overview/videos/oauth-in-the-default-aspnet-45-templates
This means a user can log in to the local web application with an external account such as Google.
Does this mean, once the user is logged in via Google, that I can then grab the Google Drive files that I need? Or is this just for making registration handling easier in the local web application?
Thanks again.
Here is my error:
[SocketException (0x274c): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond [2404:6800:4008:c01::54]:443]
System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +251
System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) +279
[WebException: Unable to connect to the remote server]
System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) +6098637
System.Net.HttpWebRequest.GetRequestStream() +13
GoogleDriveTest.WebForm1.Page_Load(Object sender, EventArgs e) in C:\Projects\GoogleDriveTest\GoogleDriveTest\GoogleDriveTest\WebForm1.aspx.cs:101
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +91
System.Web.UI.Control.LoadRecursive() +74
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207
SOLVED!!
My issue was that there is a proxy in my workplace that didn't allow any connections to the required URL. So I turned off the proxy in my browser and it bypassed it going directly the the required URL successfully getting the access token :D
Refer to the QuickStart (note the .NET tab!) that shows how to do this with the DotNetOpenAuth library.
Note the following line:
// Retrieve the access token by using the authorization code:
return arg.ProcessUserAuthorization(authCode, state);
The documentation includes a complete web application sample written in C# that you can use as reference:
https://developers.google.com/drive/examples/dotnet
It is an ASP.NET MVC application but the authorization part can be easily reused in a Web Forms application.
For more details about the authorization flow, check the documentation on how to Retrieve and Use OAuth 2.0 Credentials
We have recently moved from an online hosting provider to a local server and we are currently trying to set up a .net website with web services and are having difficulties.
We have two websites running on IIS (in Windows Server 2003) - one that is the actual website where we gain input from the user and one which is running the web services where we talk to the database / deal with logic etc...
At the moment we can display the main website page but as soon as it accesses the web services it receives the following 404 error:
The request failed with HTTP status 404: Not Found.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.WebException: The request failed with HTTP status 404: Not Found.
Source Error:
Line 1120: >[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://localhost:58605/Dev_GetVersion", RequestNamespace="http://localhost:58605", ResponseNamespace="http://localhost:58605", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
Line 1121: public string Dev_GetVersion() {
Line 1122: object[] results = this.Invoke("Dev_GetVersion", new object[0]);
Line 1123: return ((string)(results[0]));
Line 1124: }
Source File: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\b0534295\1f56ee4c\App_WebReferences.mjxicnrr.0.cs Line: 1122
Stack Trace:
[WebException: The request failed with HTTP status 404: Not Found.]
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) +431289
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) +204
IPASWebServices.AccountManagementServices.Dev_GetVersion() in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\b0534295\1f56ee4c\App_WebReferences.mjxicnrr.0.cs:1122
MasterPage.displayVersionDetails() in c:\www_ipas\MasterPage.master.cs:46
MasterPage.Page_Load(Object sender, EventArgs e) in c:\www_ipas\MasterPage.master.cs:28
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Control.LoadRecursive() +141
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
Version Information: Microsoft .NET Framework Version:2.0.50727.3082; ASP.NET Version:2.0.50727.3082
I see it's trying to access the web server and then the method ("http://localhost:58605/Dev_GetVersion") but it is leaving out the actual web service name. (It should be "http://localhost:58605/AccountManagementServices.asmx?op=Dev_GetVersion").
Any idea why it does this? It works perfectly fine on the online web hosting and on the development computer, just not in this new environment.
Make sure the App is running as an account that has the proper rights in IIS. If unsure, make sure the account the app is running as is in the IIS_WPG group.
Here is more details on properly setting up the IIS App Pool Identity: http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/12a3d96c-65ea-4210-96ad-86a801f6a88c.mspx?mfr=true