ADSI Terminal Server Extensions (IADsTSUserEx)

Hi,

I am very new to ADSI programming and am stuck on probably a simple thing.

I am getting the following error in VC++ 6.0 when compiling & executing the ADSI sample code (see below) taken straight from MSDN.

error C2065: 'IID_IADsTSUserEx' : undeclared identifier

I have imported the required "tsuserex.h" and "tsuserex.c" files for using the IADsTSUserEx class and the actual object definition compiles successfully with no problems. It just seems to be something to do with the interface on the IADsTSUserEx object that is not recognised by the compiler.

Does anyone have any advice on why this could be happening?
Thanks in advance.
Alex.

CODE-------->

IADsContainer *pContainer = NULL;
IDispatch *pNewObject = NULL;
IADsTSUserEx *pTSUser = NULL;
IADsUser *pUser = NULL;
HRESULT hr = ERROR_SUCCESS;

CoInitialize(NULL);
//
// Bind to the known container.
//
hr = ADsGetObject(L"LDAP://CN=Users,DC=Server1,DC=Domain,DC=com",
IID_IADsContainer,
(void**)&pContainer);

if( !SUCCEEDED(hr)) {
wprintf(L"ADsGetObject ret failed with 0x%x\n", hr);
return FALSE;
}
//
// Create the new Active Directory Service Interfaces User object.
//
hr = pContainer->Create(L"user",
L"cn=test3",
&pNewObject);
pContainer->Release();

if( !SUCCEEDED(hr)) {
wprintf(L"Create ret failed with 0x%x\n", hr);
return FALSE;
}
//
// Get the IADsTSUser interface from the user object.
//

hr = pNewObject->QueryInterface(IID_IADsTSUserEx, (void**)&pTSUser);

if( !SUCCEEDED(hr)) {
wprintf(L"QueryInterface for IADsTSUser failed with ret 0x%x\n", hr);
return FALSE;
}
//
// Get the IADsTSUser interface from the user object.
//
hr = pNewObject->QueryInterface(IID_IADsUser, (void**)&pUser);

if( !SUCCEEDED(hr)) {
wprintf(L"QueryInterface for IAsUser failed with 0x%x\n", hr);
return FALSE;
}
pNewObject->Release();

//
// Set TerminalServicesProfilePath
//
pTSUser->put_TerminalServicesProfilePath(L"c:\\windows");
pTSUser->Release();

//
// Commit the object data to the directory.
//
pUser->SetInfo();
pUser->Release();
CoUninitialize();

<----------
[2546 byte] By [coffeehound] at [2007-11-19 10:58:52]
# 1 Re: ADSI Terminal Server Extensions (IADsTSUserEx)
Hello,

Im sorry I dont have the answer to your question. I have a queastion to you instead.

Im also a greenhorn with ADSI-programming and I cant find "tsuserex.h" and "tsuserex.c", so my program doesnt compile at all. If you can help me where I can find these files or how to create them?

Thank you for your help!

Jakl
Jakl at 2007-11-10 3:39:09 >
# 2 Re: ADSI Terminal Server Extensions (IADsTSUserEx)
Hi Jakl,

The whole ADSI topic is pretty confusing to me, and the amount of information on the web is scarce! Unless you're using VB that is.

In the end I realised I was using an older type library. I installed the 2003 SDK and then was able to import the necessary files from tsuserex.tlb.

There is also an additional file which you need to include in your project, it is called "tsuserex_i.c". It contains the interface definitions, and is also found in the SDK.

Install the SDK from here...
http://www.microsoft.com/downloads/details.aspx?FamilyId=A55B6B43-E24F-4EA3-A93E-40C0EC4F68E5&displaylang=en

To actually get the tsuserex include files you must import the type library into your C++ project. This is done through the classwizrd in VC++ 6.0 and through Class View in VC++ 2003.

Despite this I am still getting errors with my application as the "QueryInterface" line is compiling now but still failing at runtime.

Anyway good luck and let me know how far you get and you might be able to help me out!! :)
coffeehound at 2007-11-10 3:40:13 >
# 3 Re: ADSI Terminal Server Extensions (IADsTSUserEx)
Hello Sir
I am Neeraj Student of B.Tech from INDIA.I m working with a network Project thats my Semester Project.Igot Some Problem on ADSI Programming.

Recently I am working with IADsTSUserEx Class to get Terminal Service information.But got unsuccess to do this.

I am working with VC++ plateform and wrote code that found on MSDN site.I getting error on this line :

HRESULT hr = pNewObj->QueryInterface(IID_IADsTSUserEx,(void**)&pTSUser);

Can you halp me to solve this problem?

Thanks and Regards

Neeraj.
neeraj_ji at 2007-11-10 3:41:07 >
# 4 Re: ADSI Terminal Server Extensions (IADsTSUserEx)
What libraries are you including in your project, something like adsiid.lib and actveds.lib?
f1shrman at 2007-11-10 3:42:12 >