Authentication While Browsing and Connecting

One goal of browsing in the Explorer is to be able to browse individual directories and files on the network, and reach a desired file or directory before having to make a connection. The main problem in accomplishing this is that of authentication: you cannot browse the directories on a share, for example, if you don't supply the password for the share.

This is solved by having a new WNet API for authentication. When an application attempts to enumerate the contents of a container, or access an object of some type on the network, it may receive a "not authenticated" error code. The application can then call the WNetAddConnection3 or WNetUseConnection API to gain appropriate access. WNetAddConnection3 sets up a connection to the resource, obtaining security information from the password caching subsystem or from the user using a standard dialog. Once this connection is established, the application can continue normally with its operation. Similarly, WNetUseConnection can provide a counted connection (if supported by the network), so that when the operation is finished, the application can advise the NP that it no longer is using that connection by calling WNetCancelConnection2. The underlying network can also do expiration of idle connections by itself.