Problem using WTSOpenServer on Win2003Server DC

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Christopher Attard

    Problem using WTSOpenServer on Win2003Server DC

    Hi,
    I'm using WTSOpenServer (P/Invoke in a C# application) to open a
    handle to a specified terminal server which is Win2003 Server Domain
    Controller.

    The function is returning NULL (or 0). I'm able to connect
    successfully to the terminal server when using the remote desktop program
    from a WinXP client machine.

    Any ideas or suggestions pls?

    Regards,
    Chris Attard


  • Mattias Sjögren

    #2
    Re: Problem using WTSOpenServer on Win2003Server DC

    > Any ideas or suggestions pls?

    Ensure that you have SetLastError=tr ue in your DllImport attribute,
    then call Marshal.GetLast Win32Error() after the call to
    WTSOpenServer() to get an idea about why its failing.



    Mattias

    --
    Mattias Sjögren [MVP] mattias @ mvps.org
    http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
    Please reply only to the newsgroup.

    Comment

    • Christopher Attard

      #3
      Re: Problem using WTSOpenServer on Win2003Server DC

      Yes, I'm already dong it....The error returned is: 5



      "Mattias Sjögren" <mattias.dont.w ant.spam@mvps.o rg> wrote in message
      news:uVb6GdM9EH A.3336@TK2MSFTN GP11.phx.gbl...[color=blue][color=green]
      >> Any ideas or suggestions pls?[/color]
      >
      > Ensure that you have SetLastError=tr ue in your DllImport attribute,
      > then call Marshal.GetLast Win32Error() after the call to
      > WTSOpenServer() to get an idea about why its failing.
      >
      >
      >
      > Mattias
      >
      > --
      > Mattias Sjögren [MVP] mattias @ mvps.org
      > http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
      > Please reply only to the newsgroup.[/color]


      Comment

      • Willy Denoyette [MVP]

        #4
        Re: Problem using WTSOpenServer on Win2003Server DC

        Which means "access denied".
        You have to impersonate using a privileged account's credentials (like a
        domain admins, or enterprise admins account).

        Willy.


        "Christophe r Attard" <christopher@gf i.com> wrote in message
        news:e3RjokM9EH A.2804@TK2MSFTN GP15.phx.gbl...[color=blue]
        > Yes, I'm already dong it....The error returned is: 5
        >
        >
        >
        > "Mattias Sjögren" <mattias.dont.w ant.spam@mvps.o rg> wrote in message
        > news:uVb6GdM9EH A.3336@TK2MSFTN GP11.phx.gbl...[color=green][color=darkred]
        >>> Any ideas or suggestions pls?[/color]
        >>
        >> Ensure that you have SetLastError=tr ue in your DllImport attribute,
        >> then call Marshal.GetLast Win32Error() after the call to
        >> WTSOpenServer() to get an idea about why its failing.
        >>
        >>
        >>
        >> Mattias
        >>
        >> --
        >> Mattias Sjögren [MVP] mattias @ mvps.org
        >> http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
        >> Please reply only to the newsgroup.[/color]
        >
        >[/color]


        Comment

        • Christopher Attard

          #5
          Re: Problem using WTSOpenServer on Win2003Server DC

          I'm using the Administrator account which is a member of the Domain Admins
          and still it's returning an error of 5. What seems awkward is that when I'm
          using the same account to connect to the same server through mstsc.exe, its
          creating a successful terminal session.

          Chris

          "Willy Denoyette [MVP]" <willy.denoyett e@pandora.be> wrote in message
          news:eXmaT6N9EH A.3840@tk2msftn gp13.phx.gbl...[color=blue]
          > Which means "access denied".
          > You have to impersonate using a privileged account's credentials (like a
          > domain admins, or enterprise admins account).
          >
          > Willy.
          >
          >
          > "Christophe r Attard" <christopher@gf i.com> wrote in message
          > news:e3RjokM9EH A.2804@TK2MSFTN GP15.phx.gbl...[color=green]
          >> Yes, I'm already dong it....The error returned is: 5
          >>
          >>
          >>
          >> "Mattias Sjögren" <mattias.dont.w ant.spam@mvps.o rg> wrote in message
          >> news:uVb6GdM9EH A.3336@TK2MSFTN GP11.phx.gbl...[color=darkred]
          >>>> Any ideas or suggestions pls?
          >>>
          >>> Ensure that you have SetLastError=tr ue in your DllImport attribute,
          >>> then call Marshal.GetLast Win32Error() after the call to
          >>> WTSOpenServer() to get an idea about why its failing.
          >>>
          >>>
          >>>
          >>> Mattias
          >>>
          >>> --
          >>> Mattias Sjögren [MVP] mattias @ mvps.org
          >>> http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
          >>> Please reply only to the newsgroup.[/color]
          >>
          >>[/color]
          >
          >[/color]


          Comment

          • Willy Denoyette [MVP]

            #6
            Re: Problem using WTSOpenServer on Win2003Server DC

            Should work, try using a DC administrator account.
            - check the eventlog (turn on auditing).
            - check your accounts privileges.

            Willy.

            "Christophe r Attard" <christopher@gf i.com> wrote in message
            news:ezkutcW9EH A.2316@TK2MSFTN GP15.phx.gbl...[color=blue]
            > I'm using the Administrator account which is a member of the Domain Admins
            > and still it's returning an error of 5. What seems awkward is that when
            > I'm using the same account to connect to the same server through
            > mstsc.exe, its creating a successful terminal session.
            >
            > Chris
            >
            > "Willy Denoyette [MVP]" <willy.denoyett e@pandora.be> wrote in message
            > news:eXmaT6N9EH A.3840@tk2msftn gp13.phx.gbl...[color=green]
            >> Which means "access denied".
            >> You have to impersonate using a privileged account's credentials (like a
            >> domain admins, or enterprise admins account).
            >>
            >> Willy.
            >>
            >>
            >> "Christophe r Attard" <christopher@gf i.com> wrote in message
            >> news:e3RjokM9EH A.2804@TK2MSFTN GP15.phx.gbl...[color=darkred]
            >>> Yes, I'm already dong it....The error returned is: 5
            >>>
            >>>
            >>>
            >>> "Mattias Sjögren" <mattias.dont.w ant.spam@mvps.o rg> wrote in message
            >>> news:uVb6GdM9EH A.3336@TK2MSFTN GP11.phx.gbl...
            >>>>> Any ideas or suggestions pls?
            >>>>
            >>>> Ensure that you have SetLastError=tr ue in your DllImport attribute,
            >>>> then call Marshal.GetLast Win32Error() after the call to
            >>>> WTSOpenServer() to get an idea about why its failing.
            >>>>
            >>>>
            >>>>
            >>>> Mattias
            >>>>
            >>>> --
            >>>> Mattias Sjögren [MVP] mattias @ mvps.org
            >>>> http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
            >>>> Please reply only to the newsgroup.
            >>>
            >>>[/color]
            >>
            >>[/color]
            >
            >[/color]


            Comment

            • Christopher Attard

              #7
              Re: Problem using WTSOpenServer on Win2003Server DC

              Thanks Willy...problem solved. Infact i was running the call in the security
              context of a non-administrative account.

              Chris

              "Willy Denoyette [MVP]" <willy.denoyett e@pandora.be> wrote in message
              news:eS9k7yW9EH A.2452@TK2MSFTN GP14.phx.gbl...[color=blue]
              > Should work, try using a DC administrator account.
              > - check the eventlog (turn on auditing).
              > - check your accounts privileges.
              >
              > Willy.
              >
              > "Christophe r Attard" <christopher@gf i.com> wrote in message
              > news:ezkutcW9EH A.2316@TK2MSFTN GP15.phx.gbl...[color=green]
              >> I'm using the Administrator account which is a member of the Domain
              >> Admins and still it's returning an error of 5. What seems awkward is that
              >> when I'm using the same account to connect to the same server through
              >> mstsc.exe, its creating a successful terminal session.
              >>
              >> Chris
              >>
              >> "Willy Denoyette [MVP]" <willy.denoyett e@pandora.be> wrote in message
              >> news:eXmaT6N9EH A.3840@tk2msftn gp13.phx.gbl...[color=darkred]
              >>> Which means "access denied".
              >>> You have to impersonate using a privileged account's credentials (like a
              >>> domain admins, or enterprise admins account).
              >>>
              >>> Willy.
              >>>
              >>>
              >>> "Christophe r Attard" <christopher@gf i.com> wrote in message
              >>> news:e3RjokM9EH A.2804@TK2MSFTN GP15.phx.gbl...
              >>>> Yes, I'm already dong it....The error returned is: 5
              >>>>
              >>>>
              >>>>
              >>>> "Mattias Sjögren" <mattias.dont.w ant.spam@mvps.o rg> wrote in message
              >>>> news:uVb6GdM9EH A.3336@TK2MSFTN GP11.phx.gbl...
              >>>>>> Any ideas or suggestions pls?
              >>>>>
              >>>>> Ensure that you have SetLastError=tr ue in your DllImport attribute,
              >>>>> then call Marshal.GetLast Win32Error() after the call to
              >>>>> WTSOpenServer() to get an idea about why its failing.
              >>>>>
              >>>>>
              >>>>>
              >>>>> Mattias
              >>>>>
              >>>>> --
              >>>>> Mattias Sjögren [MVP] mattias @ mvps.org
              >>>>> http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
              >>>>> Please reply only to the newsgroup.
              >>>>
              >>>>
              >>>
              >>>[/color]
              >>
              >>[/color]
              >
              >[/color]


              Comment

              Working...