question

SimonScott-1980 avatar image
0 Votes"
SimonScott-1980 asked XingyuZhao-MSFT commented

Adding domain credentials

Good morning all,

I have a scenario with the below code whereby i need to add in domain credentials. Reason being, the app is run by a user who is logged into the PC as a domain user and thus has access to the share. What i would like to do is remove the PC from the domain and then be able to run the application with some hard coded domain credentials. Here is a snippet of my code below...

strhostname = System.Net.Dns.GetHostName()
strIPAddress = System.Net.Dns.GetHostByName(strhostname).AddressList(0).ToString()
lblIPAddress.Text = "IP Address: " & strIPAddress
Try
Prefix = strhostname.Substring(0, 3)

             'Check the IP address of the local machine
             Dim ipArray() As String = Split(strIPAddress, ".")

         'Testing purposes only
         If ipArray(1) = "254" And ipArray(2) = "187" Then
             LblOffice.ForeColor = Color.Black
             LblStatus.ForeColor = Color.Green
             LblStatus.Text = "Your app is updating, please wait......."
             LblOffice.Text = "This PC Is at Head Office"
             Using sr As New StreamReader("\\filserv001\temp\temp.ini")
                 sString = sr.ReadToEnd()
             End Using

Appreciate any help you coding guru's can give me :)

Thanks
Simon

dotnet-visual-basic
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @SimonScott-1980 ,

What i would like to do is remove the PC from the domain and then be able to run the application with some hard coded domain credentials.

It seems that the PC has no rights on the share, then here's a reference you can refer to.
How to provide user name and password when connecting to a network share
You can convert the code to vb. net.
Besides, if I have any misunderstanding, please let me know.


0 Votes 0 ·

0 Answers