简体   繁体   中英

How to show a customized windows authentication with sql server

i have a table in that i listdown the Ips to allow the access of service. my service is

website/service.asmx

in that there are hundreds of web methods.

the Table name: IPTable 
Column: IP nvarchar(max)
    202.192.25.150
    215.215.215.215
    115.119.185.199

when any person hit on above service then first it check the requester ip address ,suppose if its in that list then open windows authentication popup (customize)*, else it will redirect on root website root. *Customize: by windows authentication I mean user/password will check from sql server's table H_user not actually windows users,

So my question is only that is this possible to show a customized windows authentication ?

I'm not sure how we can implement the Windows authentication for this requirement. But we can implement the customized authentication as below.

  • Create an authentication method
    • Use Request.UserHostAddress to retrieve the client IP Address
    • Check that requested IP address is valid or not (from your table)
    • If valid returns true else false
  • Call this authentication method in every web method
  • If returns true proceed next; else redirect to root site

Authentication method signature:

public bool isAuthenticatedUser()
{
   -- get requested ip address
   -- check that requested ip address is available or not
   -- if requested ip address is available in DB then allow to proceed; else redirect to root site
}

Call the method in main.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM