Adding domain credentials

Simon Scott 306 Reputation points
2021-10-05T07:51:22.39+00:00

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

VB
VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,568 questions
{count} votes