web services - ASP.Net MVC web application Impersonated doesn't react the same way out of the server -
i have developed asp.net mvc 5 web application works impersonation. i'm using impersonation because web app calling navision dynamics web services , don't want users enter credentials.
i have deployed web application on windows server 2012 r2 iis 8.5. have changed application pool .net 4.5 classic classic pipeline mode , have activated impersonation authentication.
my web application works while navigate form server internet explorer raise me “system.data.services.client.dataserviceclientexception: forbidden” error when try access computer. if stay on server , change localhost myservername in url, don't error don't receive data navision.
here system web configuration
<system.web> <compilation targetframework="4.5.1" /> <httpruntime targetframework="4.5.1" /> <authentication mode="windows" /> <authorization> <deny users="?" /> </authorization> <customerrors mode="off" /> <identity impersonate="true" /> </system.web>
here way consume navision service
using system.linq; using system.net; using system.servicemodel; using system.web; namespace mywebapplication.models { public class matter { public string matter_no { get; set; } public string matter_label { get; set; } } public static class matterdatacontext { [operationbehavior(impersonation = impersonationoption.required)] public static ienumerable<matter> getmatters() { list<matter> matterlines = new list<matter>(); uri uri = new uri(configurationmanager.appsettings["navisionodatauri"]); var nav = new navserviceref.nav(uri); nav.credentials = credentialcache.defaultnetworkcredentials; var resultmatterlines = m in nav.matterlist select m; foreach (var m in resultmatterlines) { matter ligne = new matter(); ligne.matter_no = m.matter_no; ligne.matter_label = m.matter_label; matterlines.add(ligne); } return matterlines; } } }
i have added peace of code index debug
<table border="1"> <tr> <td>application code executed using</td> <td>@system.security.principal.windowsidentity.getcurrent().name</td> </tr> <tr> <td>is user authenticated</td> <td>@user.identity.isauthenticated</td> </tr> <tr> <td>authentication type, if authenticated</td> <td>@user.identity.authenticationtype</td> </tr> <tr> <td>user name, if authenticated</td> <td>@user.identity.name</td> </tr> </table>
and receive expecting :
application code executed using: domain\jeremy
user authenticated: true
authentication type, if authenticated: ntlm
user name, if authenticated: domain\jeremy
i can't find i'm doing wrong... can me please?
you need following : - verify installed both asp.net , windows authentication on iis - once installed , iis authentication verify enabled windows authentication , impersonation , disabled anonymous access
Comments
Post a Comment