srvsvc NetShareAdd and NetNameValidate RPCs ...

Richard Sharpe realrichardsharpe at gmail.com
Sun Oct 28 16:57:24 MDT 2012


On Thu, Oct 18, 2012 at 7:24 AM, Richard Sharpe
<realrichardsharpe at gmail.com> wrote:
> On Wed, Oct 17, 2012 at 10:09 AM, Richard Sharpe
> <realrichardsharpe at gmail.com> wrote:
>> Hi folks,
>>
>> We were trying to enhance NetShareAdd so that an appropriate error is
>> returned when adding the share fails for some reason, Eg, out of
>> resources, etc. We did this by allowing the add script to write an
>> error code to STDERR (or STDOUT, I forget.)
>>
>> We tried returning error codes like WERR_NERR_NOROOM,
>> WERR_NERR_NONETWORKRESOURCE, WERR_CAN_NOT_COMPLETE and
>> WERR_NERR_UNKNOWNDEVDIR, but none of these change the behavior of
>> Computer Manager. It simply fails without telling you that it failed
>> or why it failed, it seems. You simply do not get the new share added.
>>
>> In the trace I notice that there is a call to NetNameValidate before
>> the call to NetShareAdd, and I wondered if this is the correct place
>> to actually perform verification that you have the resources to create
>> the share?
>>
>> There seem to be little documentation on NetNameValidate that I can
>> find, however.
>
> We have confirmed, with a little experimentation, that returning an
> error from NetNameValidate gets Computer Manager to pop up a dialog
> box saying that an error occurred.
>
> To exploit that would require another script, or perhaps the net share
> add script with a parameter saying validate vs one saying create for
> the NetShareAdd step.

It turns out that is the wrong way to do things(TM).

With Windows, those resources already exist (ie, the directories on
the target node).

If you have a model that might cause failure when NetShareAdd runs and
you want to communicate those errors to users, you need to write your
own MMC snapin. That, in turn, likely means you want your own RPC
sub-system.

-- 
Regards,
Richard Sharpe
(何以解憂?唯有杜康。--曹操)


More information about the samba-technical mailing list