15 April, 2022

Get Local or Remote Logon User Using Request.LogonUserIdentity.Name

Using Environment.UserName returned server name, then application pool name. That is what I encountered recently. And since I needed to know who is using that small web app, as it is logged into an Oracle table, I had to find out how to get this info correctly.

Searching the web usually and always gives a lot of answers. And you have to fish out what may work. But apparently, I had to really search for longer.

My goal is to get the logged-on user from a laptop, as well as the PC name. And aside from the failure of returning the server name, the application pool name, and even the IIS IUSR at one time, that is not what I wanted. It had to be the logged-on user, and also the machine used (Environment.MachineName).

Fortunately, I managed to piece together and make do 3 points:

1. In the server, you have to disable the Web Site's Anonymous Authentication setting.

2. Then, to get the logged-on user, use Request.LogonUserIdentity.Name.

3. Finally, get PC or computer name using System.Net.Dns.GetHostEntry(Request.ServerVariables("remote_addr")).HostName

1. Disable the Web Site's Anonymous Authentication Setting

In the server where your web application is published or deployed, select and double-click on your website. In the IIS section, double-click on Authentication. Right-click on Anonymous Authentication and select Disable if it is Enabled. Step one is done.

2. Capture Local UserName

Below is the code sample, where I employed redundancy. This will work only when step 1 is done.

Dim userName As String = Environment.UserName

Dim pcUser As String = Request.LogonUserIdentity.Name

If (pcUser.Trim.Length > 0) Then

userName = pcUser

End If

3. Capture Local Computer Name

Finally, use the below code to get the local PC or computer name. Again, this is employing redundancy.

Dim pcName As String = Environment.MachineName

Dim comp_name() As String = System.Net.Dns.GetHostEntry(Request.ServerVariables("remote_addr")).HostName.Split(New Char() {"."c})

pcName = comp_name(0).ToString()

There you go! 3 steps to capture the local user and local computer name. Nothing else, or if these steps don't work for you, then you need something else. Otherwise, you are all set. Hope this helps, how to get the local or remote logged-on user.

Till then!


16 March, 2022

Remove TFS Connection from Solution

How to remove TFS connection from solution? I was asking this question to myself. We are migrating from TFS to Tortoise, and it is taking some time for this to happen.

And meanwhile, whenever I am opening solutions to do edit on the source codes I have copied in my laptop, I get the notification: 


Team Foundation Server Version Control

The solution you are opening is bound to source control on the following Team Foundation Server: [TFS SERVER NAME]. Would you like to contact this server to try to enable source control integration?


I would click on No, do one with the code edit, debug, save, and done.

Or maybe not.

You see, the next time I open the source code, I am greeted with this question, and the source code won't load until I click on No. And again on the next edit, and so on and so forth.

So I searched the web for how to do this permanently.

Pretty quickly came one suggestion with 2 steps: 

1. Go to your solution's folder, search and destroy (read: delete) all files with *.vssscc and *.vspscc extensions.

2. Open your solution's .sln file in Notepad++ (or in a much more basic text editor such as Notepad) and remove the GlobalSection(TeamFoundationVersionControl) section.

Well, I'm in a hurry and most of the time I am even lazy to do these just 2 steps. And besides, this method requires some other steps not listed, but feel free to search for more info if you want to go this way.

Fortunately, I found another method that I can say is a one-time deal and it is done. Final.

Here's how it goes, 3 steps:

1. Open the solution, then when the prompt comes, click on No and make no mistake, click on No.

2. Once fully loaded, click on File, then Source Control, then Advanced, then Change Source Control.

3. You will be prompted with the following question, so affirmatively click on Yes.


---------------------------

Microsoft Visual Studio

---------------------------

Change Source Control - [MY_SOLUTION_NAME].sln

The current solution is associated with source control but is offline.

Would you like to completely disassociate the solution from source control?

---------------------------

Yes   No   Help   

---------------------------


How to remove TFS connection from a solution? 2 methods I have shown, with the 2nd method I have tried to be sure-fire. And that's how I am no longer bothered with the incessant "Would you like to contact this server to try to enable source control integration?" question.

If you are also bothered and you want it to stop, for good, try it. I did, and I am very much contented and now happily coding.

Till then!


02 December, 2021

Windows 11 from Official ISO Installer

Windows 11 final update was released by Microsoft a couple of weeks back. My laptops were all updated as a result.

By George! One laptop suddenly threw some errors. Then on recovery, it was unable to find the boot device!

By hardware design, I think the laptop is bound to fail in the new Windows 11 OS as there is a substantial tweak done to this laptop in Windows 7 and Windows 10. At least during the beta release, it was running.

These are the specs of the said machine:
> HP Envy TS15
> SSD: SATA and miniSATA
> 2x 8GB RAM
> current OS: Windows 10

As mentioned earlier, there is a tweak done to make the SATA and mSATA drives work together. That is done in the BIOS and in some settings in Windows.

When the production version of Windows 11 was released and this laptop was updated, the tweaks were wiped out. That caused the issue of the boot device not being found. I wasn't prepared for that, but life must go on, and that I wanted to see how the production version of Windows 11 fares. Curiouser and curiouser!

Hard way it is, so after trying several times as I did in Windows 7 and Windows 10, installing Windows 11 with the SATA and mSATA drive, or only the SATA drive then putting in the mSATA drive, changing BIOS settings, Windows settings, etc., etc., I found that Windows 11 UEFI with SecureBoot on can only work on this machine with only the SATA drive installed. And that is all the time. So I had to ditch the 512 GB mSATA drive foregoing the real-time online additional computing space.

I went for that and did a clean install of Windows 11, and voila! Lesser space and bare basics for this unit and Windows 11 64 bit UEFI was installed and running. And yes, it is a better OS than Windows 10.

Now I don't get the blue screen of death, or at least I still don't get it. Normally I would open Chrome with at least 20 tabs open and my laptop still goes through smoothly. Perhaps Windows 11 is a better OS after all.

Wanna try it? Go ahead and see how it goes. Let's hear from you soon!

Till then!