简体   繁体   中英

How do I use C# to access networks by allowing users to enter credentials?

I am writing a program in C# that needs to access certain files on my network. However on certain computers the users password and username is not saved and therefore the network cannot be accessed till they enter their credentials. Also, on certain computers we must map the network to drive before it can even get accessed.

How can I write a program, that the popup which would normally appear when accessing a network will still appear, allowing the user to enter his credentials and for my C# to not crash. Also if there is a work around to the map network drive it would be appreciated as well.

Your .exe will by default use the running users credentials, the credentials of the user are configurable via the current thread of execution.

Thread.CurrentPrincipal.Identity can be configured with the credentials of any valid user.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM