http://qs321.pair.com?node_id=904685

ToolHack has asked for the wisdom of the Perl Monks concerning the following question:

I need help setting some Terminal Server user profile settings on a 2008 Server machine. In particular, I want to uncheck the "Connect client drives at logon" checkbox. If I were a Windows hacker (which I admit, I'm not), I would apparently have to use the IADsTSUserEx interface described here http://msdn.microsoft.com/en-us/library/aa380823(VS.85).aspx

I don't understand how to do that with Perl.

What I was trying and failing with was:

$user->SetProperty('msTSConnectClientDrives', 0); $user->SetInfo();

where $user is a Win32::OLE object I created in Active Directory through LDAP.

I get the error:

Win32::OLE(0.1709) error 0x8007200b: "The attribute syntax specified to the directory service is invalid"

Replies are listed 'Best First'.
Re: Setting Terminal Server User Profile Settings
by Anonymous Monk on May 13, 2011 at 17:41 UTC
      Thanks for the links. I've read most of them.

      I'm not sure what alternate forms of SetProperty means. There is a form that takes @ARGS as a parameter before the value you want to set, but I have no idea what that is for.

      I have tried setting different values:
      SetProperty("msTSConnectClientDrives", 0); SetProperty("msTSConnectClientDrives", 'No'); SetProperty("msTSConnectClientDrives", 'False'); SetProperty("msTSConnectClientDrives", Variant(VT_BOOL,0));
      Only the last one does not give an error, but it also doesn't change the check box.

      I have been able to set other TS properties. For example, TerminalServicesHomeDirectory. None of the ones that start with msTS* work though. Maybe there is a different name I should be using?

        I'm not sure what alternate forms of SetProperty means.

        Well, if you read Win32::OLE SetProperty documentation it discusses masking, so if the object you're working with has a SetProperty method, it will conflict with Win32::OLE's method, so you have to use $obj->Invoke('SetProperty', @args )

Re: Setting Terminal Server User Profile Settings
by natxo (Scribe) on May 15, 2011 at 20:07 UTC
      I'd rather not depend on a 3rd party tool for this. I'll see if Lanman can do the job. Notice I don't consider Perl as 3rd party. ;-)

      Thanks.

        Doesn't look like Lanman is supported on Perl 5.10...