CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2005
    Posts
    2

    Question 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();

    <---------------------------------

  2. #2
    Join Date
    Aug 2005
    Posts
    1

    Question Re: ADSI Terminal Server Extensions (IADsTSUserEx)

    Hello,

    I´m sorry I don´t have the answer to your question. I have a queastion to you instead.

    I´m also a greenhorn with ADSI-programming and I can´t find "tsuserex.h" and "tsuserex.c", so my program doesn´t 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

  3. #3
    Join Date
    Jul 2005
    Posts
    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/d...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!!

  4. #4
    Join Date
    Jul 2006
    Posts
    1

    Question 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.

  5. #5
    Join Date
    Aug 2004
    Posts
    184

    Re: ADSI Terminal Server Extensions (IADsTSUserEx)

    What libraries are you including in your project, something like adsiid.lib and actveds.lib?

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured