ClearBox Server v1.2 Developer's Guide |
IServer2::ReadRADAttributeUsed by server extension to read and parse RADIUS attribute from a string. This helper function allows server extension to read radius attributes from any configuration files and pass to the server. HRESULT ReadRADAttribute( [in] BSTR attrName, [in] BSTR attrValue, [out] RADIUS_ATTRIBUTE* radAttr); Parameters
Return ValuesThis method may return S_FALSE if attribute with attrName was not found or attrValue was not parsed successfully (see Remarks). Thread SafetyThis method can be called from any thread. Memory ManagementServer extension should allocate and free memory for attrName and attrValue parameters. If the method succeeds and valType field of radAttr is RADSTR, then strValue is allocated by server and should be freed by server extension calling CoTaskMemFree if it is not NULL. If the method succeeds and valType field of radAttr is RADTXT, then txtValue is allocated by server and should be freed by server extension calling SysFreeString if it is not NULL. RemarksFirst, server remove all leading and ending spaces from attrValue string. Then, before parsing attrValue parameter, server determines value-type of the attrName attribute.
Example CodeThis code uses m_pServer as IServer interface pointer stored in ICommonExtenderEx::InitializeEx implementation. In this example server reads and parses Class attribute. ... IServer2* pS2=NULL; m_pServer->QueryInterface(IID_IServer2,(void**)&pS2; //QueryInterface will always succeed BSTR pName=SysAllocString(L" Class "); // These spaces will be removed BSTR pValue=SysAllocString(L" 0x12Affb78\""); // Spaces and quotes will be removed RADIUS_ATTRIBUTE attr; HRESULT hr=pS2->ReadRADAttribute(pName,pValue,&attr); if (hr==S_OK) { // now // attr.type is 25; //Class // attr.valType is RADSTR; // attr.dwValue is undefined // attr.strSize is 4 // attr.strValue points to an array of 4 bytes // attr.txtValue is undefined // attr.tag is undefined // attr.vendorID is 0 // attr.vendorType is 0 // attr.flags is 0x102 BYTE buf[300]; memcpy(buf,attr.strValue,attr.strSize); // use buf that contains 4 bytes CoTaskMemFree(attr.strValue); } SysFreeString(pName); SysFreeString(pValue); // Call to pS2->Release() is not necessary ... } See Also
© 2001-2003 XPerience Technologies. www.xperiencetech.com |
Created by chm2web html help conversion utility. |