Windows NT RPC Service / Name Service Database

I have a windows nt service that uses rpc.  I have been having some problems with being able to reliably obtain a binding between client and server.

When the server is installed it does the following:

// Clear the endpoints out of the binding handles
// This forces the clients through the endpoint mapper and
// reduces the volatility of the namespace entry for this service.

for(UINT i = 0; i < m_pBindingVector->Count; ++i)


According to msdn I should not keep exporting to NS each time I run...I know this info. seems to contradict all the examples they provide!...

So when I Start the service:

RegisterEndpoint();                         InitialiseSecurity();

When I stop:


This code means that I don't get stale entries in the NS as I used to when I followed earlier examples which used to export each time the service started...but I still find I have problems getting bindings sometimes, and the resolution is to uninstall and then reinstall the service, presumably reinstalling the ns entry for the service...but how does the ns entry get lost?  What is the best way to check on startup?
Who is Participating?
PinTailConnect With a Mentor Commented:
Unfortunately you have fallen victim to a known problem with Microsoft RPC, they have a hotfix available, although I have searched the site and can't find it.

The reason I know about this is that I raised this issue as a bug to them over a year ago, and provided an application that proved that the problem was in their locator service, not in my code.  They finally admitted they had a problem, it then took about six months to get it corrected.

If you don't have any luck finding the HotFix get back to me and I can give you the name of the Microsoft Techie that actually shipped me the fix.
Blondie050798Author Commented:
What exactly was the bug that you raised? Entries in the NS disappear?  Did you cater for this in your code, or did the fix they supplied simply cure it?
Does SP5 have this fix included? I notice that it seems to contain a lot of RPC related patches...?


>>What exactly was the bug that you raised?
missing or ghost entries in RPCNSLookupXXX or RPCNSBindingImportXXX

>>Entries in the NS disappear?  
Yes, I refere to these as missing. As apposed to what I call ghost entries, which are entries that the locator DB is maintaining, even though I have cleanly shut down (and de-registered) my service.

>>Did you cater for this in your code, or did the fix they supplied simply cure it?

I actally ended up writting a custom Locator Database system, because I couldn't wait for MS to fix their stuff, but they did finally provide a fix, and it seems to work.

>>Does SP5 have this fix included? I notice that it seems to contain a lot of RPC related patches...?

I think it might, I got it as a HotFix ( just locator.exe )

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Blondie050798Author Commented:
Can you send me the details you got from Microsoft, i.e. the techie...

When I raise bugs they never seem to respond, so I've given up telling them... :-(

So am I carrying out the proper actions in install, start, and stop?  I also have an uninstall which I'm unsure about.  I remove the name service entry and then all the registered endpoints:

RpcNsMgmtBindingUnexport(RPC_C_NS_SYNTAX_DEFAULT, (UCHAR*)lpszEntry, &id, RPC_C_VERS_ALL, NULL);

RPC_EP_INQ_HANDLE hInquiryContext = NULL;

iStatus = RpcMgmtEpEltInqBegin(NULL, RPC_C_EP_MATCH_BY_IF, &id, RPC_C_VERS_ALL, NULL, &hInquiryContext);
if(iStatus == RPC_S_OK)
      bool bContinue = true;

            RPC_BINDING_HANDLE hBinding = NULL;
            iStatus =  RpcMgmtEpEltInqNext(hInquiryContext, &id, &hBinding, NULL, NULL);

            if(iStatus == RPC_X_NO_MORE_ENTRIES)                        bContinue = false;            
                  iStatus =  RpcMgmtEpUnregister(NULL, &id, hBinding,      NULL);                   


      iStatus = RpcMgmtEpEltInqDone(&hInquiryContext);  

Am I carrying out all these actions correctly?

Sorry to keep dragging this question out, but It's nice to have found someone that knows about RPC...seems to be a black art...

It looks right to me.  In fact The End Point Manager is supposed to periodically validate his DB, so even if your application fails to unregister correctly ( for example in the case of a crash ), given enough time, the EPManager is supposed to know about this and delete the entry in it's EPDB.  I have never found adequate documentation which discusses things like the periodicity of the EPMngr DB flush, or how to programmatically determine the host machine for the EPMngr ( this would help because you could stop and start his locator, and this would cause his DB to be cleaned  - at least that's what I can surmise).

I can e-mail the source code to a noddy little application I sent to MS.  It basically just illustrates that there are ghost and missing entries in the EndPoint Mapper DB, no matter what you do to try to prevent it ( as far as correct shutdown, etc ).  It's a bit big for posting here.
Blondie050798Author Commented:
Great...anything you can send as regards this matter would be really useful!...

As long as I can get some kind of proof together that it is not my code but an MS bug...

Blondie050798Author Commented:
I've just had a bit of a search on the MS site, and found Article ID Q235863 dated July 1 1999...

RPC Locator Returns Duplicate or Missing Entries to RpcNsBindingLookup Calls...

This appears to be the problem that you mentioned, although it states that 'if you use these function sets in a mixed Windows NT version 3.51 and 4.0 domain, you may observe duplicate or missing binding handles being returned by the call' environment is totally this article appears to be saying the fault does not apply to my situation...?!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.