Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3242804
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:21:29+00:00 2026-05-17T18:21:29+00:00

Question: I have a document management system, and I am building a Web-Service interfaces

  • 0

Question: I have a document management system, and I am building a Web-Service interfaces to the database.

Everything works so far, just that right now, it’s totally unsecured, everybody can access it.

How can I incorporate password or private-public key authentication ?

I can only find ‘best practises’ and using ‘windows user’ or passport authentication.
But I need authentication from a user and password stored in the database, or better for an RSA private-key stored for each web-service user in the database…

Edit:
I have to use the .NET Framework 2.0 in an ASP.NET environment

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T18:21:29+00:00Added an answer on May 17, 2026 at 6:21 pm

    The solution is to write an own http module with a mixture of code provided by MSDN and CodeProject. Including own fixes of MS bugs, and then add this custom soap header to the web service.

    <SoapHeader("Authentication", Required:=True)>
    

    This is the module:

    Imports System.Web
    Imports System.Web.Services.Protocols
    
    
    ' http://msdn.microsoft.com/en-us/library/9z52by6a.aspx
    ' http://msdn.microsoft.com/en-us/library/9z52by6a(VS.80).aspx
    
    
    
    
    ' http://www.codeproject.com/KB/cpp/authforwebservices.aspx
    
    
    ' http://aleemkhan.wordpress.com/2007/09/18/using-wse-30-for-web-service-authentication/
    ' http://www.codeproject.com/KB/WCF/CustomUserNamePassAuth2.aspx
    ' http://www.codeproject.com/KB/WCF/CustomUserNamePassAuth2.aspx
    ' http://www.codeproject.com/KB/webservices/WS-Security.aspx
    
    
    
    
    'Public NotInheritable Class WebServiceAuthenticationModule
    Public Class WebServiceAuthenticationModule
        Implements System.Web.IHttpModule
    
        Protected Delegate Sub WebServiceAuthenticationEventHandler(ByVal sender As [Object], ByVal e As WebServiceAuthenticationEvent)
        Protected _eventHandler As WebServiceAuthenticationEventHandler = Nothing
    
    
    
        Protected Custom Event Authenticate As WebServiceAuthenticationEventHandler
            AddHandler(ByVal value As WebServiceAuthenticationEventHandler)
                _eventHandler = value
            End AddHandler
            RemoveHandler(ByVal value As WebServiceAuthenticationEventHandler)
                _eventHandler = value
            End RemoveHandler
            RaiseEvent(ByVal sender As Object,
                    ByVal e As WebServiceAuthenticationEvent)
            End RaiseEvent
        End Event
    
    
        Protected app As HttpApplication
    
    
        Public Sub Init(ByVal context As System.Web.HttpApplication) Implements System.Web.IHttpModule.Init
            app = context
    
            context.Context.Response.Write("<h1>Test</h1>")
    
            AddHandler app.AuthenticateRequest, AddressOf Me.OnEnter
        End Sub
    
    
        Public Sub Dispose() Implements System.Web.IHttpModule.Dispose
            ' add clean-up code here if required
        End Sub
    
    
        Protected Sub OnAuthenticate(ByVal e As WebServiceAuthenticationEvent)
            If _eventHandler Is Nothing Then
                Return
            End If
            _eventHandler(Me, e)
            If Not (e.User Is Nothing) Then
                e.Context.User = e.Principal
            End If
    
        End Sub 'OnAuthenticate 
    
    
        Public ReadOnly Property ModuleName() As String
            Get
                Return "WebServiceAuthentication"
            End Get
        End Property
    
    
        Sub OnEnter(ByVal [source] As [Object], ByVal eventArgs As EventArgs)
            'Dim app As HttpApplication = CType([source], HttpApplication)
            'app = CType([source], HttpApplication)
            Dim context As HttpContext = app.Context
            Dim HttpStream As System.IO.Stream = context.Request.InputStream
    
            ' Save the current position of stream.
            Dim posStream As Long = HttpStream.Position
    
            ' If the request contains an HTTP_SOAPACTION 
            ' header, look at this message.
    
            'For Each str As String In context.Request.ServerVariables.AllKeys
    
            'If context.Request.ServerVariables(Str) IsNot Nothing Then
            'context.Response.Write("<h1>" + Str() + "= " + context.Request.ServerVariables(Str) + "</h1>")
            'End If
            'Next
            If context.Request.ServerVariables("HTTP_SOAPACTION") Is Nothing Then
                'context.Response.End()
                Return
                'Else
                'MsgBox(New System.IO.StreamReader(context.Request.InputStream).ReadToEnd())
            End If
    
    
            ' Load the body of the HTTP message
            ' into an XML document.
            Dim dom As New System.Xml.XmlDocument()
            Dim soapUser As String
            Dim soapPassword As String
    
            Try
                dom.Load(HttpStream)
    
                'dom.Save("C:\Users\Administrator\Desktop\SoapRequest.xml")
                ' Reset the stream position.
                HttpStream.Position = posStream
    
                ' Bind to the Authentication header.
                soapUser = dom.GetElementsByTagName("Username").Item(0).InnerText
                soapPassword = dom.GetElementsByTagName("Password").Item(0).InnerText
            Catch e As Exception
                ' Reset the position of stream.
                HttpStream.Position = posStream
    
                ' Throw a SOAP exception.
                Dim name As New System.Xml.XmlQualifiedName("Load")
                Dim ssoapException As New SoapException("Unable to read SOAP request", name, e)
                context.Response.StatusCode = System.Net.HttpStatusCode.Unauthorized
                context.Response.StatusDescription = "Access denied."
    
                ' context.Response.Write(ssoapException.ToString())
                'Dim x As New System.Xml.Serialization.XmlSerializer(GetType(SoapException))
                'context.Response.ContentType = "text/xml"
                'x.Serialize(context.Response.OutputStream, ssoapException)
    
    
                'Throw ssoapException
    
                context.Response.End()
            End Try
    
            ' Raise the custom global.asax event.
            OnAuthenticate(New WebServiceAuthenticationEvent(context, soapUser, soapPassword))
            Return
        End Sub 'OnEnter
    
    
    End Class ' WebServiceAuthenticationModule
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Another basic Rails question: I have a database table that needs to contain references
I have interview for an internship with company that wants to implement document management
Question: I have a question that is apparently not answered by this already-asked Bash
Question We have a large number of xml configuration files that we want merged
From a previous question I have seen that the CLR has workstation and server
A simple question: I have a Model-View-Controller setup, with Models accessing a SQL database.
In our project we want to query a document management system for a specific
I have a web application that needs to be built using PHP/MySQL. The application
I am currently working on a document management system in ASP.NET 3.5 using the
Basic question - I have a UIWebView with a pdf document loaded. How can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.