ThinkGeo.com    |     Documentation    |     Premium Support

CustomOverlays ShapeFileFeatureLayers Null when using Impersonation

Our team recently updated the security in accessing files on our server through impersonating the forms. I am able to access the our shapefiles manually; however, when we add a LayerOverlay containing ShapeFileFeatureLayers to the CustomOverlays of the map control we receive tiles on the map with “Object reference not set to an instance of an object”. Upon debugging I discovered it is coming from the DrawCore function of the ShapeFileFeatureLayer. Here is a screen shot showing the tiles https://www.screencast.com/t/TZjw7UCOiQ. Is there a way to work with ShapeFileFeatureLayer and impersonation?

Thank you,

Neil

Hi Neil,

I tested that and it still works, I think that should related with whether your account get correct security.

Here is how I test that.

  1. Use the same sample in your other post 8595 here: 5895.zip (172.3 KB)

Then add this node under system.web in web.config

<identity impersonate="true"
  userName="domain\user" 
  password="password" />

Please modify the domain, user, and password here.

Then I display the shape file correct.

If I hadn’t test follow incorrect way please let me know.

I viewed some topic about this setting, it looks you can check something like this:

  1. Check your security of target folder for your specified user account.
  2. If your test project is placed in some special folder, maybe you need add your user to some special user group.
  3. Try to remove the “identity” node, directly set that in IIS7, you can find the ASP.NET Impersonation there.

Any further information or test result please let us know.

Regards,

Don

Thanks Don,

I looked into this further and the sample project you sent me worked with our server shapefiles. I noticed it was using version 10 so I upgraded our project to 10.1. I am going to get to testing it but I keep getting the pink tiles indicating an error. The title src is “tile_GeoResource.axd?BBOX=-13593575.057891,4487134.6624302,-13588683.090975,4492026.6293458&CACHEID=&CLIENTID=ContentPlaceHolder1_objMap&EXTRA=13100439439&FORMAT=image%2Fpng&HEIGHT=256&OId=ASSET&OVERLAYID=ASSET&PAGENAME=JGnhNU7BnEhIeipI94jhg&SRS=EPSG%3A900913&STYLES=&WIDTH=256&ZOOM=13”. I am also receiving a few 500 client side errors with failing to load bg_GeoResource.axd and adornment_GeoResource.axd. Must be missing something. Once I get this resolved I will move into the impersonation.

Thanks again,

Neil

Also I feel the serversession is related to this issue.

Hi Neil,

I think if you upgraded to version 10, you can directly install the package from NuGet, it will automatic copy the dlls into necessary folders.

If your exception is caused by missing dll, this way can solve it.

And I think maybe you can try to build a new empty project, reference the packages and then copy code from your original project to see whether it works. If the new project works, that means some setting in the IDE is different, you can try to find that via compare two projects.

Regards,

Don

Hi Don,

I was able to fix the issues with the exceptions on the map; however, the issues of shapefiles not being loaded still persists. My team members and I debugged the issues further and found some cases where the files were loaded and when they weren’t. We noticed when we were using Express IIS on the sample project the shapefiles would load on the map but when we used Local IIS they would not. We noticed that the Express IIS loads with “http” while Local IIS loads with “https”. Our project needs to work with Local IIS. In addition, in our project we are limiting impersonation to specific forms only and we do not want to impersonate the whole project. Here is a sample on the web.config of how we are doing that impersonations for the forms that have maps on.

<location path="Forms/GISToolbox/GISReporting">
        <system.web>
            <identity impersonate="true" userName="domain\username" password="*" />
        </system.web>
    </location>

Also for additional information we have our virtual machine set up through Hyper-V. We also are able to access the files on our virtual machines in our own code and it only seems the issues occur on the dlls functions.

We were wondering if this additional information may be useful.

Thank you,

Neil

Hi Neil,

Because environment reason, we cannot reproduce that under IIS, so cannot go on working on this problem today, I think we can start to work for it next Monday.

Regards,

Don

Hi Don,

Thought I would give you a quick update. We decided at the time to update the identity of the project in the application pool for IIS, like you suggested. This seemed to work in loading all the shapefiles. We are not sure we want to continue with this way for the future but will work with it for the time being. I did notice our adornment layer is not loading when sessionState is in “StateServer” but loads in “InProc”.

Thanks again,

Neil

Hi Neil,

Thanks for your update, we just fixed the license problem so we can test that today.

I think our developer will try to do more test for different session state and see whether we can enhancement it.

Any further information or question please let us know.

Regards,

Don