[Samba] [NetBIOS] Registering new name?

SM sm at resistor.net
Sat Aug 25 15:55:07 GMT 2007


Hi Gilles,
At 05:29 21-08-2007, Gilles Ganault wrote:
>I'm trying to register a new name on a server so that clients can 
>locate it by broadcasting its NetBIOS name.
>
>At this point, this little VB code does register the name 
>successfully, but it's not listed in "net name" and "net send" to it fails:
>
>======
>Private Sub Command1_Click()
>     Dim ncbInfo As NCB
>     Dim sMachine As String * NCBNAMSZ
>     Dim bRet As Byte
>
>     '===========1. Send RESET
>     With ncbInfo
>         .ncb_command = NCBRESET
>     End With
>     bRet = Netbios(ncbInfo)
>     MsgBox ncbInfo.ncb_retcode, , ncbInfo.ncb_num
>
>     '===========2. Register name
>     sMachine = SERVER_NAME & Chr(3)
>     With ncbInfo
>         .ncb_command = NCBADDNAME
>         .ncb_name = sMachine
>         '.ncb_lana_num = &H0
>     End With

.ncb_name is a Byte array.

>     bRet = Netbios(ncbInfo)
>     MsgBox ncbInfo.ncb_retcode, , ncbInfo.ncb_num

You are assuming that the NetBios call will return the correct value 
of .ncb_retcode after that call has been complicated.  The code may 
not have registered the NetBIOS name successfully.  You should verify 
the value of .ncb_cmd_cplt and only lookup the .ncb_retcode value 
after the NetBios command has been completed.

Regards,
-sm 



More information about the samba mailing list