This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- FlexNet Connect
- :
- FlexNet Connect Forum
- :
- Similar result with C#
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jun 26, 2006
06:33 PM
IUpdateEx3->Authenticate issue
I am trying to use the Authenticate API call in a C++ program. Here is the relevant code:
[CODE]SAFEARRAYBOUND bounds[2];
bounds[0].lLbound = 0;
bounds[0].cElements = 2;
bounds[1].lLbound = 0;
bounds[1].cElements = 2;
SAFEARRAY *psaFields = ::SafeArrayCreate(VT_BSTR, 2, bounds);
_variant_t varEl1 = L"LocationID";
_variant_t varEl2 = L"161560001";
long vecIdx[2];
vecIdx[0] = 0;
vecIdx[1] = 0;
SafeArrayPutElement (psaFields, vecIdx, (void*)(BSTR*)(&varEl1));
vecIdx[1] = 1;
SafeArrayPutElement (psaFields, vecIdx, (void*)(BSTR*)(&varEl2));
varEl1 = L"Password";
varEl2 = L"password";
vecIdx[0] = 1;
vecIdx[1] = 0;
SafeArrayPutElement (psaFields, vecIdx, (void*)(BSTR*)(&varEl1));
vecIdx[1] = 1;
SafeArrayPutElement (psaFields, vecIdx, (void*)(BSTR*)(&varEl2));
VARIANT varSafeArray;
::VariantInit (&varSafeArray);
varSafeArray.parray = psaFields;
varSafeArray.vt = VT_ARRAY;
VARIANT varRes;
::VariantInit (&varRes);
long lRet = 0;
hr = pUp->Authenticate (&varSafeArray, &varRes, &lRet);[/CODE]
The documentation indicates that the lRet value will return a 1 on success, -1 on connection failure, and 0 on auth failure. the varRes value should contain an error string on Authentication failure.
I am getting hr = S_OK and lRes = 0 (Authentication failure), but there is no message in the varRes indicating what the problem was.
We put logging in the ASP page to indicate when it is hit, and determined that it is not. Am I sending an invalid parameter to the Authenticate function? The SAFEARRAY values (at [0, 0] and [1, 0] are the same values I get from GetAuthenticationParameters(). I've also tried initializing the string result parameter to a set BSTR value, and the function pukes big-time.
We are not using the Agent UI -- all of our update calls will occur in code, so we need to authenticate via code.
-- Thanks
[CODE]SAFEARRAYBOUND bounds[2];
bounds[0].lLbound = 0;
bounds[0].cElements = 2;
bounds[1].lLbound = 0;
bounds[1].cElements = 2;
SAFEARRAY *psaFields = ::SafeArrayCreate(VT_BSTR, 2, bounds);
_variant_t varEl1 = L"LocationID";
_variant_t varEl2 = L"161560001";
long vecIdx[2];
vecIdx[0] = 0;
vecIdx[1] = 0;
SafeArrayPutElement (psaFields, vecIdx, (void*)(BSTR*)(&varEl1));
vecIdx[1] = 1;
SafeArrayPutElement (psaFields, vecIdx, (void*)(BSTR*)(&varEl2));
varEl1 = L"Password";
varEl2 = L"password";
vecIdx[0] = 1;
vecIdx[1] = 0;
SafeArrayPutElement (psaFields, vecIdx, (void*)(BSTR*)(&varEl1));
vecIdx[1] = 1;
SafeArrayPutElement (psaFields, vecIdx, (void*)(BSTR*)(&varEl2));
VARIANT varSafeArray;
::VariantInit (&varSafeArray);
varSafeArray.parray = psaFields;
varSafeArray.vt = VT_ARRAY;
VARIANT varRes;
::VariantInit (&varRes);
long lRet = 0;
hr = pUp->Authenticate (&varSafeArray, &varRes, &lRet);[/CODE]
The documentation indicates that the lRet value will return a 1 on success, -1 on connection failure, and 0 on auth failure. the varRes value should contain an error string on Authentication failure.
I am getting hr = S_OK and lRes = 0 (Authentication failure), but there is no message in the varRes indicating what the problem was.
We put logging in the ASP page to indicate when it is hit, and determined that it is not. Am I sending an invalid parameter to the Authenticate function? The SAFEARRAY values (at [0, 0] and [1, 0] are the same values I get from GetAuthenticationParameters(). I've also tried initializing the string result parameter to a set BSTR value, and the function pukes big-time.
We are not using the Agent UI -- all of our update calls will occur in code, so we need to authenticate via code.
-- Thanks
(2) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 25, 2006
11:54 AM
I'm attempting to use the same method, only in C#.
object saParams = retParams;
string temp = "";
object oTemp = temp;
//update.AutoAuthenticate();
int rez = update.Authenticate(ref saParams, ref oTemp);
update.Download(false);
Running this way, rez is set to 0 and oTemp is still null after the call. If i comment that out and use update.AutoAuthenticate() instead, the usual dialog comes up, I enter my valid response, and update.Download() works correctly.
My string array, retParams, is 2 dimentional with one name/value pair.
retParams.SetValue(authParams.GetValue(i, 0).ToString(), i, 0);
retParams.SetValue("valid string", i, 1);
When update.Authenticate is called, it appears to return immediately. At first, I thought maybe it was trying to authenticate to the wrong server, but I wouldn't have gotten this far if I didn't get the enumerated updates for my product from the correct server.
I have verified that my string array, retParams, is [1,2] with the retParams[0,0] = "MyASPParameter" and retParams[0,1] = "valid response".
Can someone please respond to this if I'm doing it completely wrong, or if I got it correct but maybe there's a bug??? 🙂
Thanks,
Sean
object saParams = retParams;
string temp = "";
object oTemp = temp;
//update.AutoAuthenticate();
int rez = update.Authenticate(ref saParams, ref oTemp);
update.Download(false);
Running this way, rez is set to 0 and oTemp is still null after the call. If i comment that out and use update.AutoAuthenticate() instead, the usual dialog comes up, I enter my valid response, and update.Download() works correctly.
My string array, retParams, is 2 dimentional with one name/value pair.
retParams.SetValue(authParams.GetValue(i, 0).ToString(), i, 0);
retParams.SetValue("valid string", i, 1);
When update.Authenticate is called, it appears to return immediately. At first, I thought maybe it was trying to authenticate to the wrong server, but I wouldn't have gotten this far if I didn't get the enumerated updates for my product from the correct server.
I have verified that my string array, retParams, is [1,2] with the retParams[0,0] = "MyASPParameter" and retParams[0,1] = "valid response".
Can someone please respond to this if I'm doing it completely wrong, or if I got it correct but maybe there's a bug??? 🙂
Thanks,
Sean
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Oct 26, 2006
12:12 PM
Authenticate API needs the url of the authentication server and it does not allow you specify it via the API call. The API gets the url from the GetAuthenticationParameters API. So you must call that API first.
Also, you need to create a safearray of VARIANTs, not BSTRs.
Also, you need to create a safearray of VARIANTs, not BSTRs.