[jcifs] midlc parse error

Michael B Allen ioplex at gmail.com
Wed Sep 14 11:46:31 MDT 2011

On Wed, Sep 14, 2011 at 1:31 PM, Robert Doerr <samba at robertdoerr.de> wrote:
> 13.09.2011 18:53, Michael B Allen:
>> On Sun, Sep 11, 2011 at 3:00 AM, Robert Doerr<samba at robertdoerr.de>
>>  wrote:
>>> Hello,
>>> I get some parse error when trying to compile the idl for the net
>>> shutdown command and am not sure if I did right.
>>> Here are my steps so far:
>>> - compiled midlc under cygwin
>>> - extracted three IDL-Files from [MS-RSP].pdf (download from microsoft):
>>> initshutdown.idl, windowsshutdown.idl winreg.idl
>>> - executed ./midlc<filename>    for all three files
>>> For each file I get a parse failure from midlc for line 4. This line
>>> looks like (example from windowsshutdown.idl):
>>>  [size_is(MaximumLength / 2), length_is((Length) / 2) ] unsigned short*
>>> Buffer;
>>> The corresponding lines in the other files look similar.
>>> midlc stops in parse.c on line 69 with the message "invalid attribute".
>>> What am I doing wrong?
>> Hi Robert,
>> Midlc only supports a subset of Microsoft IDL so copying and pasting
>> from Microsoft literature is almost certainly not going to work. You
>> will need to narrow down and isolate things a little. However in this
>> particular case I know for a fact midlc can handle that input. That
>> whole line is actually part of the definition for UNICODE_STRING which
>> is very common in JCIFS RPCs compiled with midlc. Look at
>> src/jcifs/dcerpc/rpc.idl and you will see a definition for
>> unicode_string with the same IDL in it.  Try copying that typedef and
>> replace the corresponding chunk of IDL with that unicode_string
>> definition. Study the various idl included with JCIFS in
>> src/jcifs/dcerpc/msrpc/*.idl to get a better idea of what midlc wants.
>> With a little work you should be able to get it to work no problem.
>> Mike
> Hi Michael,
> thanks for pushing me in the right direction! After looking at the files you
> mentioned it was clear what's going on.
> Unfortuately the WindowsShutdown interface (the one I actually need) uses
> RPC over TCP/IP transport (ncacn_ip_tcp).

That shouldn't matter. It should work over a named pipe I think.

> Below the reworked windowsshutdown.idl which compiles correctly (with
> rpc.idl in the same directory) for further reference.
> Regards
> Robert
> windowsshutdown.idl:
> [
> uuid(d95afe70-a6d5-4259-822e-2c84da1ddb0d),
> pointer_default( unique ),
> version(1.0)
> ]
> interface WindowsShutdown {
>    import "rpc.idl";

You will need to add [op(0xNN)] attributes before each function
definition to indicate the operation number in hex (unless there
really are only two calls in the interface 0x01 and 0x02). You can
look these numbers up through Google or in the MS documentation.

Also note that midlc does not have any validation so it might look
like it has successfully compiled something when in fact it has
produced garbage. So you will likely need to play around with it a
little to make sure that the IDL is what midlc expects.

But once you have a .java file for your interface, the
SID.getServerSid() method is a good example of how to actually fire a
single RPC call.


Michael B Allen
Java Active Directory Integration

>    unsigned long WsdrInitiateShutdown(
>        [ in ] policy_handle Binding,
>        [ in, unique ] unicode_string lpMessage,
>        [ in ] unsigned long dwGracePeriod,
>        [ in ] unsigned long dwShudownFlags,
>        [ in ] unsigned long dwReason,
>        [ in, unique ] unicode_string lpClientHint
>    );
>    unsigned long WsdrAbortShutdown(
>        [ in ] policy_handle Binding,
>        [ in, unique ] unicode_string lpClientHint
>    );
> }

More information about the jCIFS mailing list