Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2012
    Posts
    5

    Unanswered: Issue with sp_OAMethod when using setcredentials

    Hi,

    I am trying to set the basic authentication for one of the test site.

    My code is below

    declare @URL varchar(512)
    declare @post varchar(4000)
    declare @WebLogin varchar(128)
    declare @WebPassword varchar(128)
    declare @http int
    declare @Doing varchar(512)
    declare @status int
    declare @desc varchar(512)
    declare @src varchar(255)
    declare @chrXML XML

    SET @chrXML =
    '<?xml version="1.0" encoding="utf-8"?>
    <request method="client.list">
    </request>'


    set @URL ='http://httpbin.org/basic-auth/user1/user1'
    set @WebLogin = 'user1'
    set @WebPassword = 'user1'

    exec @status = master.dbo.sp_OACreate 'MSXML2.XMLHTTP', @http output
    IF @status < 0 BEGIN
    EXEC @status = sp_OAGetErrorInfo @http
    END

    set @Doing = 'Open("POST, null" , "' + @URL + '", 0 )'
    exec @status = sp_OAMethod @http, @Doing
    IF @status < 0 BEGIN
    EXEC @status = sp_OAGetErrorInfo @http
    END

    EXEC sp_OAMethod @http, 'setRequestHeader', NULL, 'Content-Type', 'text/xml'
    EXEC sp_OAMethod @http, 'setRequestHeader', NULL, 'Content-Length'

    set @Doing = 'SetCredentials("' + @WebLogin + '","' + @WebPassword + '",0)'
    exec @status = sp_OAMethod @http, @Doing
    print @status
    IF @status < 0 BEGIN
    EXEC @status = sp_OAGetErrorInfo @http
    END

    When the code setcredentials is executed it gives error

    -2147352570

    Error Source Description HelpFile HelpID
    ---------- ------------------------- -------------- -------- -----------
    0x80020006 ODSOLE Extended Procedure Unknown name. NULL 0

    Can anyone help me where I am going wrong and how to resolve this.

    I am using sql server 2005.

    Thanks in advance,

  2. #2
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    I am pretty sure that the sp_OA* procedures have been deprecated, so you might not want to spend a lot of time with them. Granting permissions on them gets to be a major security hole, too. Any chance you can wrap what you need to do in a CLR procedure, and write up the authentication in a .NET language of your choice?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •