• Авторизация


WebServices authentication in IIS6. 06-03-2005 01:45 к комментариям - к полной версии - понравилось!


Чтобы понять, как работает authentication, напишем простой Web service с одним методом :


[WebMethod]


public string GetUserIdentity()


{


      try


      {


            IPrincipal principal = base.User;


            string strUserName = principal.Identity.Name;


                 


            return strUserName;


      }


      catch


      {


            return null;


      }


}


Для того, чтобы этот код исполнял именно то, для чего он предназначен - вернуть имя того, кто его запускает (это совсем не одно и то же, что currently logged user), понадобятся 2 дополнительные настройки –Directory Security option from IIS Admin и его  web.config. Во-первых, IIS Admin. Если включить Enable Anonymous Access, то никакой authentication просто не будет производиться. В этом, собственно, и состоит смысл anonymous access. Т.е. для начала он должен быть убран. Теперь web.config. Its authentication section is just duplicates the IIS Admin options and hence confusing. Bear in mind that Web Services are configured thru web.config to bring the illusion of independency on IIS for multi-platform deployment. Whatever! Just make this section to look like


<authentication mode="Windows" />


and execute the Web method.


Conclusion : never deploy Web Service with enabled anonymous access in IIS Admin. This makes your authentication code (and web.config settings as well) senseless.


 
вверх^ к полной версии понравилось! в evernote


Вы сейчас не можете прокомментировать это сообщение.

Дневник WebServices authentication in IIS6. | Oleg_Kleiman - Soft kibitzing | Лента друзей Oleg_Kleiman / Полная версия Добавить в друзья Страницы: раньше»