Question

So the core thing what I'm trying to do is get the disk space from a other Device that is on the same network.

I use the PHP function disk_total_space() for this. I'm using the connecting string \\192.168.0.1\c$.

So in total I would have:

disk_total_space('\\\\192.168.0.1\\c$');

However, I have some questions about this connection string, to begin with:

  1. With what protocol does this 'URL' connect?
  2. why does it need a $ at the end of the driver?

Now I also need to give username and password with my connection string. However I don't know how to fuse this with the connection string I have. I tried to give the username and password with an FTP-protocol and an HTTPS-protocol, but none seems to work.

https:\\\\username:password@\\\\192.168.0.1\\c$
ftp:\\\\username:password@\\\\192.168.0.1\\c$

As you might notice I'm new to these protocols, so I hope anyone could explain this to me.

Était-ce utile?

La solution

I know nothing about php, but it seems like to answer this question you need no php knowledge... Hope this helps:

1. With what protocol does this 'url' connect?

This is called UNC Path. See more details from wiki: Path (computing)

Quote:

A UNC path describes the location of a volume, directory, or file. The format for a UNC path is \\server\volume\directory\file and is not case-sensitive.

2. Why does it need a $ at the end of the driver?

The $ stands for a hidden share, see more from Microsoft Knowledge Base

3. For your last question, 'Passing UNC username and password within a UNC path'

There is an answer to a similar question on SuperUser.

Quote answer from @grawity's answer

On Windows, you cannot put credentials in UNC paths. You must provide them using net use, runas /netonly, or when asked by Windows. (If you have some programming skills, you can store the SMB password as a "domain credential" using CredWrite(), which is equivalent to checking the "Remember password" box in Windows.)

On Linux, it depends on the program.

  • GNOME's Gvfs accepts the user@host syntax, but appears to completely ignore the password. (However, you can store it in GNOME Keyring beforehand.)

  • smbclient uses the same UNC syntax as Windows; however, it has an --authentication-file option from which credentials could be read.

  • Both programs above are using libsmbclient, and can use Kerberos authentication instead of passwords: run kinit user@YOUR.DOMAIN and use smbclient -k //host/share. This is more secure than password authentication.

Note that putting passwords into URIs is deprecated, and you should not rely on it being supported anywhere.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top