What are the different ways to programmatically connect to a nfs shared folder? How important is the use of guid and uid for this conenction?

Hi, so I have currently shared a nfs folder from linux, enabled nfs features in windows and I am now able to mount this folder as a drive.

On enabling unsecured logins I can also access this using the address bar in file explorer. I want to know if it is possible to connect to the nfs share using WNetAddConnection() API, In the event viewer I can see that this defaults to smb when attempting to connect and also manages to connect but sets an error code 67, but then I want to know why it works with the address bar in file explorer.

If I try to operate on the path directly with APIs like createfilew etc it seems to work(after enabling insecure guest login), but some APIs seem to trigger crowdstrike falcon or defender as malicious behaviour.

Also according to some resources online I need to set guid and uid to be able to write to the folder/drive. I have done this in registry, I want to know if these can be done programmatically and is absolutely necessary or if there are other ways of doing this.

The event where wnedaddconnection() seems to have been successful
Image

Also is there a way to do secured login for this nfs share instead of doing insecure login, because currently I get error 67 for this.

Thanks in advance for taking the time to view and answering this.

***Moved from Windows / Windows 11 / Files, folders, and storage***

|

Hello,  Sloth_Lord

 

Welcome to Microsoft Community.  

 

Thanks for your feedback,To programmatically connect to an NFS shared folder, you can use the "mount" command in Linux or the "mount" command in Windows Subsystem for Linux (WSL). You can also use the "mount" command in PowerShell or the "net use" command in Command Prompt to connect to the NFS share.

 

The use of GUID and UID is important for NFS connections because it helps to identify the user and group ownership of files and folders on the NFS share. This is necessary for proper file permissions and access control.

 

Regarding your question about connecting to the NFS share using the WNetAddConnection() API, this API is designed for connecting to SMB shares, not NFS shares. That's why it defaults to SMB when attempting to connect. The reason why it works with the address bar in File Explorer is that File Explorer has built-in support for NFS shares.

 

If you want to operate on the path directly with APIs like CreateFileW, you need to use the UNC path to the NFS share (e.g. \\server\share). However, some APIs may trigger security software like CrowdStrike Falcon or Defender as malicious behavior because they are not designed to work with NFS shares.

 

To set the GUID and UID programmatically, you can use the "nfsadmin" command in Windows or the "chown" command in Linux. However, it's important to note that this is only necessary if you need to write to the NFS share and the file permissions are not set correctly.

 

Regarding your question about secured login for the NFS share, you can use Kerberos authentication to secure the NFS share. However, this requires additional configuration on both the NFS server and client.

 

Additionally, if you need more professional support, I recommend trying to seek help on Microsoft Learn, where there are more experts in relevant fields who can provide you with better solutions.

 

I hope the information above can help you.If my understanding is wrong, please point it out, so that I can assist you better.    

 

Lugoo Bei | Microsoft Community Support Specialist    

Welcome to Microsoft Answers!

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

This helps. Thanks a bunch.

If you want to operate on the path directly with APIs like CreateFileW, you need to use the UNC path to the NFS share (e.g. \\server\share). However, some APIs may trigger security software like CrowdStrike Falcon or Defender as malicious behavior because they are not designed to work with NFS shares.

 

To set the GUID and UID programmatically, you can use the "nfsadmin" command in Windows or the "chown" command in Linux. However, it's important to note that this is only necessary if you need to write to the NFS share and the file permissions are not set correctly. 

One follow up query. So, I should be able connect to these shares using the "Add network location" option in explorer?
And what does "if you need to write to the NFS share and the file permissions are not set correctly" mean? If I need to write I need to set these values, or if I need to write AND file permissions are incorrect then this is a way to get it working?

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated March 26, 2025 Views 91 Applies to: