Get User Location Information using EKTRON API - api

I have an ektron application and I am using the following code to get user location information,
try
{
string IP = HttpContext.Current.Request["remote_addr"];
if (!string.IsNullOrEmpty(HttpContext.Current.Request["ip"]))
IP = HttpContext.Current.Request["ip"];
else
IP="my system ip";
//var userData = Ektron.Cms.UserContext.GetLocationInfo(IP);
//var userData = Ektron.Cms.UserContext.GetLocationInfo("my system ip");
//Ektron.Cms.UserLocationData userData = Ektron.Cms.UserContext.GetCurrentUserLocationInfo();
//var userData = Ektron.Cms.UserContext.GetLocationInfo(IP);
visitorCountry = userData.CountryCode;
}
In the above code I have tried 4 different methods (these are commented by //) to get userData. But I am getting null value in all these 4 attempts that's why I'm getting exception in userData.CountryCode;
How can I resolve this?
In IP I am getting value as ::1 and Ektron.Cms.UserContext.IP is also giving value ::1
I am using ektron 8.7

I don't have v8.7 running right now, but I do have v9, and here's what I found:
I ran the following code:
var location = Ektron.Cms.UserContext.GetLocationInfo("74.125.225.113");
Response.Write("<pre>" + Ektron.Cms.UserContext.IP + "</pre>");
Response.Write("<pre>" + string.Format("{0}, {1} ({2} / {3})", location.City, location.Region, location.Longitude, location.Latitude) + "</pre>");
Here's what was displayed on the screen:
::1
Mountain View, CA (-122.057403564453 / 37.4192047119141)
I'm running the site locally on my dev machine, so I'm browsing to http://localhost/test.aspx - no real surprise that Ektron.Cms.UserContext.IP is returning "::1" for me. I didn't have access to a server, so I pinged www.google.com and got an IP address of 74.125.225.113. Using that IP address, Ektron gave me a non-null response.
I thought I had v8.61 installed as well, but when I ran the same code in that environment, I got the following error: System.ArgumentException: Unable to find the requested .Net Framework Data Provider. It may not be installed.
I'll try to clean up my v8.6 install and see if the code works there as well, but in the meantime, I'd try using some known IP addresses and see if you get better results.

Related

ggmap error: HTTP 400 Bad Request The Google Maps Platform server rejected your request. The provided API key is invalid

I am trying to retrieve a ggmap background map using get_map() in R but I keep getting an error message "HTTP 400 Bad Request The Google Maps Platform server rejected your request. The provided API key is invalid.".
Examples:
BA <- get_map("Buenos Aires, Argentina", source = "stamen", maptype = "toner-lite", zoom = 11)
spainmap<- ggmap(get_googlemap(center = c(lon = -3.703790, lat = 40.416775), zoom = 10, maptype = 'terrain', color = 'color'))
I know that every user must have a valid google API key, I´ve created a billing account and my key is definitely valid. I´ve also enabled all the APIs, including Geocoding, Geolocation, Maps Embed and Maps Static since others suggested this.
I´ve reinstalled the latest version of R and Rstudio, restarted R session multiple times but nothing seems to work.
According to this website https://developers.google.com/maps/documentation/maps-static/error-messages I´m getting the error because some required parameter is either missing or is invalid, but I really don´t think that´s the case since I´ve tried to get maps in different locations and using various ggmap functions but nothing works.
How do I fix this? Has anyone else had this problem?

parsing JSON returns old data

so I have some database on hosting, I created a PHP script to make this data accessible for my flutter app, so now I'm accessing this data like this.[![enter image description here][1]][1]
getMethod() async {
String theUrl = 'https://tchakrulo.space/getData.php';
var res = await http
.get(Uri.parse(theUrl), headers: {'Accept': 'application/json'});
var responseBody = await json.decode(res.body);
return responseBody;
}
everything works fine except when I'm adding a new entry or updating an existing one somehow my app still returns old data, even after restarting the app, so I want to get new data from json, every time the page loads
Perhaps your values ​​are somehow cached, so if I were you, I would enter the command "flutter clean" into the console and remove the application from your device / emulator, and then reinstall it, if the problem persists, then you probably have a mistake in the code, double-check the correctness of the queries, as well as using the command print("Value: " + value.toString()); to check the values ​​that you get through the console, try to track the path along which the values ​​​​go and you will understand everything. All I can do is just give you an algorithm for solving your problem.

Adding user to Active Directory Group .net core: A referral was returned from the server

I'm building a .net core 3 website where I'm trying to add a user to an Active Directory security group. The below code works fine in my development environment but once it's deployed to IIS I receive:
System.DirectoryServices.DirectoryServicesCOMException (0x8007202B):
A referral was returned from the server.
The error occurs at "group.Save();"
using (PrincipalContext pc = new PrincipalContext(ContextType.Domain, "ad.xxx.com:389",
"DC=ad,DC=xxx,DC=com", svcAccountUsername, svcAccountPw))
{
GroupPrincipal group = GroupPrincipal.FindByIdentity(pc, IdentityType.SamAccountName, groupName);
group.Members.Add(pc, IdentityType.SamAccountName, username);
group.Save();
}
Again, this works locally in my development environment but not once deployed to IIS. Any suggestions on how to fix?
I would suggest looking up the account that you are trying to add to the AD. Other things i can suggest is using the debugger to confirm the account / group exists in the domain that you are running this under.
using (PrincipalContext pc = new PrincipalContext(ContextType.Domain, "domain" ...))
{
GroupPrincipal group = GroupPrincipal.FindByIdentity(pc, IdentityType.SamAccountName, groupName);
// Do some validation / logging to make sure there is a group returned.
var principal = Principal.FindByIdentity(pc, IdentityType.SamAccountName, username);
// Do some validation here to make sure principal is not null
group.Members.Add(principal);
group.Save();
}
Make sure the server running this script has access to the domain you are updating.
A referral means that you aren't talking to the right server, but the server knows who you should be talking to. If you look into the exception object more, you might even find which server it wants to send you to.
This can happen if the group is not on the same domain that you passed to the PrincipalContext.

SSRS ReportViewer fails when using parameters

I'm using the ReportViewer control in VS2010.
In my local and development environments when I use:
ReportParameter[] toReportParameterList = new ReportParameter[1];
toReportParameterList[0] = new ReportParameter("intApplicationID", Session["APPLICATION_ID"]);
rvFinancialSummaryReport.ServerReport.SetParameters(toReportParameterList);
Everything works properly.
When I try to do the exact same thing in my Staging/Beta environment, I get an HTTP 401 not authorized error.
When I comment out those three lines, the report parameter section loads and I can get the report correctly when I type in the parameter.
Any idea why trying to pass parameters via the server report, I get an HTTP 401?
EDIT
I should probably add that I am sending credential information as such:
string tsUserNameDomain = ConfigurationManager.AppSettings["ReportUserName"].ToString();
string tsDomain = tsUserNameDomain.Substring(0, tsUserNameDomain.IndexOf("\\"));
string tsUsername = tsUserNameDomain.Substring(tsUserNameDomain.IndexOf("\\") + 1);
string tsPassword = ConfigurationManager.AppSettings["ReportPassword"].ToString();
ReportViewerCredentials toCredentials = new ReportViewerCredentials(tsUsername, tsPassword, tsDomain);
rvFinancialSummaryReport.ServerReport.ReportServerCredentials = toCredentials;
This works as long as there is no parameters set.
EDIT
Just to Reiterate... when I comment this line:
rvFinancialSummaryReport.ServerReport.SetParameters(toReportParameterList);
It works...
When I uncomment this line:
rvFinancialSummaryReport.ServerReport.SetParameters(toReportParameterList);
I get an HTTP 401: Unauthorized.
EDIT
Another detail... my SSRS server is HTTP, my IIS is HTTPS...
It would seem that the order of operations in this scenario is important.
After some extensive testing on a local server, I realized that after the parameter value was set, when I went to set the credential values the parameter array object on the server report was coming back as null.
I moved the instantiation of the credential object to the top of the page load, and now everything is working properly.

how to set HTTP_HOST for WebTestCases in Symfony2

My application is generating some absolute links via $this->get('request')->getHost().
Problem is: when I try to run testcases, I get following error message:
[exception] 500 | Internal Server Error | Twig_Error_Runtime
[message] An exception has been thrown during the rendering of a template ("Undefined index: HTTP_HOST") in "::base.html.twig" at line 69.
Somehow it's clear to me that there is no host when calling my app via CLI, but I think there must be a way to prevent Symfony2 from throwing that error.
Anyone knows how to get rid of it?
You could create the request like this:
$request = Request::create('http://example.com/path');
That will make the HTTP host be set.
Maybe what you could do is to inject the host you need directly in the request headers before calling the getter. The host is retrieved by looking at various parameter values. First, the headers parameter X_FORWARDED_HOST is checked to see if it is set. If it is set, it is returned otherwise the method getHost checks if the headers parameter HOST is set then the if the server parameter SERVER_NAME is set and finally if the server parameter SERVER_ADDR is set.
What you could try is to set the header parameter HOST like this before calling the getHost method:
$request = $this->get('request');
$request->headers->set('HOST', 'yourhosthere');
$request->getHost(); // Should return yourhosthere
That being said, I'm not sure this will solve the problem because the error you mentioning tells us that the template tries to retrieve the value of the index HTTP_HOST but it is not defined. Looking at the methods $request->getHost and $request->getHttpHost, I don't see anything trying to retrieve a value having HTTP_HOST as the index but I could have missed it. Could you post the file ::base.html.twig to see if the problem could be lying there.
Regards,
Matt
Thanks guys- your answers lead me into the right direction.
This is no Symfony2 issue, as i figured out:
It's just the facebook API PHP wrapper which directly accesses the SERVER parameters. This code solved my issue:
$facebook = $this->container->get('facebook');
$returnUrl = 'http://'.$request->getHost();
$returnUrl .= $this->container->get('router')->generate('_validate_facebook');
$_SERVER['HTTP_HOST'] = $request->getHost();
$_SERVER['REQUEST_URI'] = $request->getRequestUri();
$loginUrl = $facebook->getLoginUrl(array(
'req_perms' => 'publish_stream',
'next' => $returnUrl,
));
return $loginUrl;
now my app runs from web and CLI again