In my code, I am trying to open a directory of Solaris OS from Windows OS using FindFirstFile().

In Windows XP, the code is working fine but in Window 7 same code is not working.

FindFirstFile() returns INVALID HANDLE in Windows 7 and GetLastError() return error code 50,

which means "The request is not supported. "

Can anybody help me out why the same code working fine in Windows XP but not in Windows 7 ??

I tried with disabling all the firewalls in Windows 7 but the result were same.

Here is the sample code :

int _tmain(int argc, _TCHAR* argv[])
{
        char             *path = "\\\\mach_name\\usr1\\usrname\\mydir\\*.*";
        wchar_t        wstr[256];
        HANDLE        filehandle;
        WIN32_FIND_DATAW  fileinfoW;
        DWORD        i;

        mbstowcs (wstr, path, 256);
        filehandle  = FindFirstFileW(wstr, &fileinfoW);
        if (filehandle != INVALID_HANDLE_VALUE)
FindClose(filehandle);
else
                i = GetLastError();

        return 0;
}

It works fine in XP but in Windows 7 FindFirstFile() returns INVALID_HANDLE_VALUE and then GetLastError() reports Error Code 50.

Response awaited..

Thanks in advance

Dani AI

Generated

Short summary and practical fixes (expands on and )

The symptom you saw — a UNC call failing (FindFirstFileW returning INVALID_HANDLE_VALUE) and GetLastError() == 50 — is usually an SMB/NTLM negotiation failure, not a bug in FindFirstFile. Error 50 is ERROR_NOT_SUPPORTED from Win32. (learn.microsoft.com)

Why it happens
Windows 7 (and Vista+/modern Windows) prefer NTLMv2 and refuse older LM/NTLM by default; older Samba/SMB stacks on Solaris may only accept LM/NTLM. That mismatch causes the SMB open to fail during negotiation. (learn.microsoft.com)

Quick, safe steps to resolve

  • Prefer a server-side fix: upgrade/configure the Samba on the Solaris box so it supports NTLMv2. Modern Samba defaults to NTLMv2 behavior; changing server settings is the secure fix. (samba.org)

  • If you must change the Windows client for compatibility (temporary), edit the LAN Manager auth policy:

    1. Run secpol.msc -> Local Policies -> Security Options -> "Network security: LAN Manager authentication level".
    2. For best security, use "Send NTLMv2 response only. Refuse LM & NTLM". For compatibility with older servers you can choose the less strict option (examples below). Changes can also be made via the LmCompatibilityLevel registry value. (learn.microsoft.com)

Example registry change (run elevated):

reg add "HKLM\SYSTEM\CurrentControlSet\Control\Lsa" /v LmCompatibilityLevel /t REG_DWORD /d 1 /f

(Here 1 corresponds to "Send LM & NTLM - use NTLMv2 session security if negotiated"; use 3 or 5 for stronger NTLMv2-only settings). (learn.microsoft.com)

Samba-side options and testing
If changing the server, look at smb.conf options like ntlm auth and lanman auth — these control whether NTLMv1/LM are permitted; avoid enabling LM unless you have no alternative. Use smbclient or net use \\server\share and packet capture (Wireshark) to observe the SMB auth handshake while you iterate. (samba.org)

Caveats
Relaxing LAN Manager settings reduces security and may be overridden by domain Group Policy; prefer updating the Samba stack or enabling NTLMv2 on the server. See Microsoft docs on the policy and registry mapping for exact numeric values before changing production machines. (learn.microsoft.com)

Recommended Answers

All 3 Replies

Looks like someone over at "" is already answering this....

But, to be complete, I pasted the code into a new VS2008 project and ran it on my 64-bit Windows 7 installation, and it ran just fine.

On a subsequent run, I deliberately messed up the machine name but in that case got an error code 53 - ERROR_BAD_NETPATH.

What version of Visual Studio are you running? What version (32-bit/64-bit) of Windows 7 are you using?

Looks like someone over at "" is already answering this....

But, to be complete, I pasted the code into a new VS2008 project and ran it on my 64-bit Windows 7 installation, and it ran just fine.

On a subsequent run, I deliberately messed up the machine name but in that case got an error code 53 - ERROR_BAD_NETPATH.

What version of Visual Studio are you running? What version (32-bit/64-bit) of Windows 7 are you using?

I am using 64 bit Windows 7 and Visual Studio 2008.
Please note that, I am trying to access directory that exists on a machine having Solaris OS installed on it.

I am using 64 bit Windows 7 and Visual Studio 2008.
Please note that, I am trying to access directory that exists on a machine having Solaris OS installed on it.

Hi,

I found the solution of my problem.

Actually "LAN Manager Authentication level" (Local Security Policy) was not set properly.

So, Windows 7 was not able to communicate to SAMBA server running on Solaris.

If, for someone, "LAN Manager Authentication level" is set properly and still he/she facing the same problem then one of the possible solution could be in the link below:

http://www.sevenforums.com/network-sharing/46680-windows-cannot-access-computer.html

Thanks..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.