I got "Often Misused: Authentication" issue while fortify done my code scan. I am getting issue from below line of code
IPHostEntry serverHost = Dns.GetHostEntry(HttpContext.Current.Server.MachineName);
When I Googled I found some solutions but I am unable to get it. Do I need to create a False positive for this issue or Can I rewrite the code and give a fix. This is used only for logging purpose. I am not satisfied with creating FP ticket. How can i get serverhost without using Dns.GetHostEntry.Can anybody suggest any fix for this issue.
Related
I have tried the C# sample at https://learn.microsoft.com/en-us/azure/azure-monitor/platform/data-collector-api butI always get an error response back. Has anyone been able to get this sample to work? I have double and triply checked the workstation id and the secret key but still cannot call the API sucessfully.
Yes, as Doris Lv mentioned, displaying the error would certainly help to understand the issue better.
In additional to it what I could observe in general is, the C# example provided for the Azure Monitor Data Collector API uses ASCII encoding while other parts of the page reference UTF8 so try to tweak your code with UTF8 and see if it resolves your error.
I'm trying to retrieve the SignalStrength (i.e. like the info behind the bars cellular phones), but on a desktop application developed in C# .NET 4.0, that has a GSM adapter connected to it. I've managed to connect and disconnect to the service provider using RasDialer, but I can't find anyway to get the SignalStrength.
I've tried MbnApi, but it runs great until I receive the connected interfaces, and after I use one of them for ANYthing, it crashes with a COM exception saying "the data necessary to complete this operation is not yet available". Here's a piece of code that crashes with this exception on the last line:
MbnInterfaceManager mbnInfMgr = new MbnInterfaceManager();
IMbnInterfaceManager infMgr = (IMbnInterfaceManager)mbnInfMgr;
MbnConnectionManager mbnConnectionMgr = new MbnConnectionManager();
IMbnConnectionManager ImbnConnectionMgr = (IMbnConnectionManager)mbnConnectionMgr;
var mobileInterface = infMgr.GetInterfaces() as IMbnInterface[];
IMbnSignal sig = (IMbnSignal)mobileInterface[0];
uint signalStrength = sig.GetSignalStrength();
Can anyone assist, either by explaining what I'm doing wrong with MbnApi or directing me to another alternative?
Thank you so much in advance,
Yaron.
I couldn't see any obvious errors, so I pasted your exact code into a .NET 4.0 test project, referenced MbnApi built on a Windows 8 system and ran it, and it ran fine. I got the signal strength of my integrated modem out.
I assume that in your code, you would normally have try/catch blocks, tests for null etc.
Have you investigated how many interfaces are present, and whether you really want interface[0] or another one? Also obvious things like re-booting Windows etc.
You asked about other possibilities for getting this information.
When using MBN API for signal strength, you should be aware of this factor. The AT command AT+CESQ gives a more accurate value. Section 8.69 of this document describes it. There is plenty of information on SO and the internet on how to use AT commands with C# - try the at-command tag, or do a search for [c#][at-command] on SO.
I have an interesting problem that I am trying to solve. I have the following code below which is basically a function for merging values with an html file and giving me the result set. I am using a hashtable for those purposes.
The function is as follows (Please bear in mind that I inherited this functionality and cannot be changed at present)
public static string ParseTemplate(string _FileName, int _NumberofSomething)
{
Hashtable templateVars = new Hashtable();
templateVars.Add("NameOfFile", _FileName);
templateVars.Add("NumberOfSomething", _NumberofSomething);
TemplateParser.Parser parser =
new TemplateParser.Parser(
System.Web.HttpContext
.Current.Server.MapPath("~/docs/Templatenr.htm"), templateVars);
return parser.Parse();
}
On our dev and live servers it is working perfectly. However I am trying to deploy the app to another production server and get an "object reference not set to an instance of object". It breaks exactly on the "Hashtable templateVars = new Hashtable();" line. So I am a bit puzzled. If it was a coding problem it should not work everywhere surely?
The only differences between the different production servers are the OS and IIS that is running. ie. Server 2005 and IIS7 vs Server2003 and IIS6 (which is the environment that it breaks on). Both have .net framework up to 3.5 installed. Could the older OS and ISS be the problem? Is it a maybe permission/memory thing? though that sounds a bit implausible since all the other .net functionality I am using on the new production server is working perfectly.
All the issues regarding the hashtable that I found, relates to it not being instantiated. However my error happens on the line that is trying to instantiate a Hashtable.
Has anyone had an error like this before and if so how did you solve it? I'd even appreciate suggestions on what to look for and I'll give it a try. I'll post back the outcome too, if anyone else is experiencing this error in future.
I never really got to the bottom of this error. Suggestions for using remote debugging with Reflector Pro did not work either, pointing to some issues with the virtual server the website was running in. Checking log files showed other errors that the .net framework threw out.
The website was moved to a new virtual server using IIS7 and windows server 2008. It worked as is on the new environment.
This is maybe not the ideal solution for everybody and maybe a framework re-install could have solved our problem, but since we were in the process of changing over to a new environment (for other reasons) this solution suited us.
Im getting a ConfigurationException whenever i try to perform QueryService.Query or QueryService.ExQuery. Same goes when i do GetSearchMetadata().
I can however do a GetPortalSearchInfo() and Status() without problems.
Any hint of what can cause the problem?
This was due to a missing hotfix:
windows6.1-kb976462-ia64.msu
I'm working on some code that dropped on me when another developer (and the only person who knew anything about this system) left. I'm trying to figure out why my client and server are not connecting. I'm getting the following error:
"Genuine channels operation exception: The connection has been forcibly closed.
Specified reason: RSA encryption failed with error code = -2146893819"
Initial google research seems to indicate that Genuine Channels is a communications library that was being used (but I'm not sure if that's accurate). Also, there doesn't seem to be any information on what that particular error code means.
At this point, I'm fine with suggestions on where to give my research if you don't have any concrete ideas on what could be wrong.
Error code -2146893819 is hex 80090005 which, in the MS crypto libraries, is NTE_BAD_DATA.
That's about as far as I got before I lost interest (that tends to happen to me a lot with crypto stuff) and it's only slightly more helpful than what you've got, so I've made it community wiki.
You haven't actually stated what you were doing when you got the error but the top hit for "rsa" and "nte_bad_data" on Google was this.
Still, it expands you Google search terms at least :-)
Best of luck.
For reference to future people who visit this question, I eventually solved this issue. It turned out to be a a DLL mismatch between the versions of GenuineChannels & our cryptology implementation that were on our client machines and our server machines.