none
WebProxy not working on Windows 10 RRS feed

  • Question

  • I am using Windows update Agent API for search windows updates. It's not working on Windows 10 Pro, in case of configure web proxy on that machine. In that scenario, getting following error.

    Same as HTTP status 407 - proxy authentication is required.

    Friday, September 22, 2017 12:23 PM

All replies

  • Hello,

    to help you, we need more information. Show us your code how you configure your web proxy.

    Regards, Guido

    Friday, September 22, 2017 12:36 PM
  • Hello,

    This is my code for configure web proxy, It's working before apply march updates on windows 10

            CoInitialize(NULL);
    IUpdateSession* pUpdateSession = NULL;
    IUpdateServiceManager* pUpdateServiceManager = NULL;
    IUpdateService* pUpdateService = NULL;
    IUpdateSearcher* pUpdateSearcher = NULL;

    // create update session object.

    HRESULT hr = CoCreateInstance(CLSID_UpdateSession, NULL, CLSCTX_INPROC_SERVER, IID_IUpdateSession, (void**)&pUpdateSession);

    if(FAILED(hr)||pUpdateSession == NULL) 
    {
    LOG_MESSAGE(AGENT_LIFE_CYCLE_SYNC, "Failed to create instance of UpdateSession: %d", GetLastError());
    nRetCode = FAILURE;
    return nRetCode;
    }
    // Testing purpose for proxy server
    IWebProxy* pWebProxy = NULL;
    hr = CoCreateInstance(CLSID_WebProxy, NULL, CLSCTX_INPROC_SERVER, IID_IWebProxy,(void**)&pWebProxy);
    if(FAILED(hr)||pWebProxy == NULL) 
    {
    LOG_MESSAGE(AGENT_LIFE_CYCLE_SYNC, "Failed to create instance of Web Proxy: %d", GetLastError());
    nRetCode = FAILURE;
    return nRetCode;
    }

    BSTR Address = SysAllocString(L"192.168.4.225:8080");
    BSTR User = SysAllocString(L"test.vdi.com");
    BSTR Password = SysAllocString(L"abc");
    ////BSTR User = SysAllocString(L"");
    ////BSTR Password = SysAllocString(L"");


    ////pWebProxy->put_AutoDetect(VARIANT_TRUE);
    //
    ////pWebProxy->put_BypassProxyOnLocal(VARIANT_TRUE);
    pWebProxy->put_Address(SysAllocString(Address));
    pWebProxy->put_UserName(SysAllocString(User));
    pWebProxy->SetPassword(SysAllocString(Password));

    hr = pUpdateSession->put_WebProxy(pWebProxy);
    if(FAILED(hr)) 
    {
    LOG_MESSAGE(AGENT_LIFE_CYCLE_SYNC, "Failed to put_WebProxy: %d", HRESULT_CODE(hr));
    nRetCode = FAILURE;
    return nRetCode;
    }
    // Testing purpose for proxy server

    // create update service manager object.
    hr = CoCreateInstance(CLSID_UpdateServiceManager, NULL, CLSCTX_INPROC_SERVER, IID_IUpdateServiceManager,(void**)&pUpdateServiceManager);

    if(FAILED(hr)||pUpdateServiceManager == NULL) 
    {
    LOG_MESSAGE(AGENT_LIFE_CYCLE_SYNC, "Failed to create instance of UpdateServiceManager: %d", GetLastError());
    nRetCode = FAILURE;
    return nRetCode;
    }

    // create update searcher object.
    hr = pUpdateSession->CreateUpdateSearcher(&pUpdateSearcher);

    if ( FAILED(hr) || pUpdateSearcher == NULL ) 
    {
    LOG_MESSAGE(AGENT_LIFE_CYCLE_SYNC, "Failed to create Update Searcher: %d", GetLastError());
    nRetCode = FAILURE;
    return nRetCode;
    }

    // select the update server source.
    hr = pUpdateSearcher->put_ServerSelection(ssWindowsUpdate);
    //hr = pUpdateSearcher->put_ServerSelection(ssDefault);
    hr = pUpdateSearcher->put_CanAutomaticallyUpgradeService(VARIANT_TRUE);
    hr = pUpdateSearcher->put_IncludePotentiallySupersededUpdates(VARIANT_FALSE); // Modified by Harshada 3rd July 2015
    hr = pUpdateSearcher->put_Online(VARIANT_TRUE);

    ISearchResult* pSearchResult = NULL;
    ISearchJob* pjob  =NULL;
    ISearchCompletedCallbackArgs* pCompletedCallbackArgs = NULL;
    IUnknown* pcallbak;
    VARIANT var;
    IEnumVARIANT *pEnum = NULL;
    MyCallBackClass callback;
    callback.Invoke(pjob,pCompletedCallbackArgs);
    pcallbak =(IUnknown*)&callback;

    HRESULT hRes = NULL;
    var.vt = VT_BOOL;
    var.boolVal = VARIANT_TRUE;
    VariantInit(&var);
    VariantChangeType(&var, &var, 0, VT_BOOL);

    pcallbak->AddRef();
    hRes = pcallbak->QueryInterface(IID_IUnknown,(void**)&pEnum);

    if(FAILED(hRes)) 
    {
    LOG_MESSAGE(AGENT_LIFE_CYCLE_SYNC, "Failed to Query interface: %d", GetLastError());
    nRetCode = FAILURE;
    return nRetCode;
    }

    // Special the criteria. Details in MSDN (Synchronous)
    //BSTR criteria = SysAllocString(L"IsInstalled = 1"); //(L"IsInstalled = 0 and IsHidden = 1");
    BSTR criteria = SysAllocString(L"Type = 'Software' and IsInstalled = 0");
    hr = pUpdateSearcher->BeginSearch(criteria, pcallbak, var, &pjob);

    if ( FAILED(hr) )
    {
    LOG_MESSAGE(AGENT_LIFE_CYCLE_SYNC, "Failed to BeginSearch : %d", GetLastError());
    nRetCode = FAILURE;
    return nRetCode;
    }

    hr = pjob->get_IsCompleted(&var.boolVal);

    if ( FAILED(hr) )
    {
    LOG_MESSAGE(AGENT_LIFE_CYCLE_SYNC, "Failed to get_IsCompleted : %d", GetLastError());
    nRetCode = FAILURE;
    return nRetCode;
    }
    if ( SUCCEEDED(hr) )
    {
    LOG_MESSAGE(AGENT_LIFE_CYCLE_SYNC, "Begin Search");

    hr = pUpdateSearcher->EndSearch(pjob, &pSearchResult);

    if ( FAILED(hr) || pSearchResult == NULL)
    {
    switch (hr)
    {
    case WU_E_PT_WINHTTP_NAME_NOT_RESOLVED:
    LOG_MESSAGE(AGENT_LIFE_CYCLE_SYNC, "The proxy server or target server name cannot be resolved.");
    break;
    case WU_E_PT_HTTP_STATUS_PROXY_AUTH_REQ:
    LOG_MESSAGE(AGENT_LIFE_CYCLE_SYNC, "Same as HTTP status 407 - proxy authentication is required.");
    break;

    }
    fnDisplayError(hr);
    //LOG_MESSAGE(AGENT_LIFE_CYCLE_SYNC, "Failed to End Search : %S", GetHresultErrorAsString(hr));
    nRetCode = FAILURE;
    pjob->CleanUp();
    return nRetCode;
    }
    if(pSearchResult != NULL)
    {

    }
    }

    VariantClear(&var);
    pcallbak->Release();

    Thank you..

    Monday, September 25, 2017 10:08 AM
  • Hello,

          Actually above code is working in case of run as a Administrator. But when we try with Local System user or Admin (member of Administrator) in that scenario it's not working.

    Thank you.

    Tuesday, September 26, 2017 5:21 AM
  • Hi,

    thanks for posting here.

    >>Actually above code is working in case of run as a Administrator. But when we try with Local System user or Admin (member of Administrator) in that scenario it's not working.

    For this case, you could use LogonUser  method to log an administrator account on. 

    According to MSDN document, System administrators can use WUA to programmatically determine which updates should be applied to a computer, download those updates, and then install them with little or no user intervention. Independent software vendors (ISV) and end-user developers can integrate WUA features into computer management or update management software to provide a seamless operating environment.

    Hope this could be help of you.

    Best Regards,

    Sera Yu


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Proposed as answer by Guido Franzke Wednesday, September 27, 2017 6:45 AM
    Wednesday, September 27, 2017 2:04 AM
  • Hi,

    If your issue has been resolved, please remember to close your thread by marking useful posts as answer that can be helpful for other person with same issue.

    Best Regards,

    Hart


    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, September 29, 2017 8:05 AM
    Moderator
  • Hi,

    Issue not resolved yet, but I observed one thing. It's working for without authentication Proxy server. 

    Is it any limitation after March update for windows 10.

    Thanks & Regards,

    Thursday, January 4, 2018 10:17 AM