rubicon-oss / LicenseHeaderManager

Manage license headers for your source code files in Visual Studio
179 stars 41 forks source link

%UserDisplayName% is not expanding to a value #133

Open onpremdiag opened 4 years ago

onpremdiag commented 4 years ago

This was previously working: Exception caught while trying to lookup the display name with 'UserPrincipal.Current.DisplayName'. Stacktrace: System.InvalidCastException: Unable to cast object of type 'System.DirectoryServices.AccountManagement.GroupPrincipal' to type 'System.DirectoryServices.AccountManagement.UserPrincipal'. at System.DirectoryServices.AccountManagement.UserPrincipal.FindByIdentity(PrincipalContext context, IdentityType identityType, String identityValue) at System.DirectoryServices.AccountManagement.UserPrincipal.get_Current() at LicenseHeaderManager.Headers.UserInfo.TryLookupNow() in C:\Build\1776828f99d31c99\LicenseHeaderManager\Headers\UserInfo.cs:line 83

Microsoft Visual Studio Enterprise 2019 Version 16.7.6 VisualStudio.16.Release/16.7.6+30611.23 Microsoft .NET Framework Version 4.8.04084

Installed Version: Enterprise

ASP.NET and Web Tools 2019 16.7.532.28833 ASP.NET Core Razor Language Services 16.1.0.2035807+72d099b977d3a85e65fa3b0614ca8cfc803fef02 ASP.NET Web Frameworks and Tools 2019 16.7.532.28833 Azure App Service Tools v3.0.0 16.7.532.28833 Azure Functions and Web Jobs Tools 16.7.532.28833 C# Tools 3.7.0-6.20459.4+7ee7c540e3bf19765695b1331c946ddf986d1516 Code alignment 14.1.107.0 CodeMaid 11.1.209 Common Azure Tools 1.10 Cookiecutter 16.7.20248.6 Generate GUID for Visual Studio 2012 1.0 GitHub.VisualStudio 2.11.106.19330 IntelliCode Extension 1.0 License Header Manager 3.0.3 Markdown Editor 1.12.253 Microsoft Azure Tools 2.9 Microsoft Azure Tools for Microsoft Visual Studio 2019 - v2.9.30701.1 Microsoft Continuous Delivery Tools for Visual Studio 0.4 Microsoft JVM Debugger 1.0 Microsoft Library Manager 2.1.79+ge3567815aa.RR Microsoft MI-Based Debugger 1.0 Microsoft Visual Studio Tools for Containers 1.1 Node.js Tools 1.5.20701.1 Commit Hash:b0da3724234b78593207434292d9f891440edea1 NuGet Package Manager 5.7.0 PowerShell Pro Tools for Visual Studio 1.0 ProjectServicesPackage Extension 1.0 Python 16.7.20248.6 Python - Conda support 16.7.20248.6 Python - Django support 16.7.20248.6 Python - IronPython support 16.7.20248.6 Python - Profiling support 16.7.20248.6 RemoveTrailingWhitespaces 1.0 Snapshot Debugging Extension 1.0 SQL Server Data Tools 16.0.62008.03130 TypeScript Tools 16.0.20702.2001 Visual Basic Tools 3.7.0-6.20459.4+7ee7c540e3bf19765695b1331c946ddf986d1516 Visual F# Tools 10.10.0.0 for F# 4.7 16.7.0-beta.20361.3+3ef6f0b514198c0bfa6c2c09fefe41a740b024d5 Microsoft Visual F# Tools 10.10.0.0 for F# 4.7 Visual Studio Code Debug Adapter Host Package 1.0 Visual Studio Container Tools Extensions (Preview) 1.0 Visual Studio Tools for Containers 1.0 Visual Studio Tools for Containers

Stefan-Ilic commented 4 years ago

Hi @onpremdiag,

thank you for your report. I was unfortunately unable to reproduce this on my machine. Could you, in addition to the other helpful version information you already provided, tell me which Windows 10 Version and OS build you're using? You can look this up under your Windows Settings > System > About. In addition, would you kindly tell me if your user account

With this information, I'll be able to narrow down my investigations.

Best Regards, Stefan

MichaelKetting commented 4 years ago

see also https://github.com/rubicon-oss/LicenseHeaderManager/issues/97

onpremdiag commented 4 years ago

My user account is being administered via AD. This was working previously (no changes that I'm aware of). I have tried with Windows Pin, Windows Hello, and UserID/Password-based authentication. All produce the same result.

Edition Windows 10 Enterprise Version 20H2 Installed on ‎10/‎7/‎2020 OS build 19042.572 Serial number 004866402157 Experience Windows Feature Experience Pack 120.2212.31.0

Stefan-Ilic commented 4 years ago

Hi @onpremdiag,

I'll get back to you as soon as I get my hands on a Windows 20H2 and can try it out for myself.

Best regards, Stefan

Stefan-Ilic commented 4 years ago

Just to make sure: When you say this was working previously, did you update LicenseHeaderManager at all? Or was it working before you updated to Windows 20H2 and the update broke it?

onpremdiag commented 4 years ago

Neither :-(. I'm running the same version of LicenseHeaderManager (3.0.3) on both. Both machines are running the same version of Windows and VS2019.

Stefan-Ilic commented 4 years ago

Both? Are you saying that you have two PCs with identical Windows versions and VS versions and that LicenseHeaderManager works on one of them but not the other?

When you said that it was working previously, I assumed it worked on Machine A and then suddenly didn't work on Machine A anymore.

onpremdiag commented 4 years ago

That is correct: Machine A (where it works) and Machine B (where it does not work). They appear to be identically configured. I'm seeing a slight difference in behavior on Machine A: Working Working

Not Working NotWorking

pravincar commented 3 years ago

Just ran into the same issue. My Windows 10 account is managed by an organization. Also I'm logged in via RDP to the Windows machine. Do you have a workaround that you can suggest? Thanks

RolandWH commented 2 years ago

Issue

Hi, I am also having this issue but unlike issue #97 and @onpremdiag it is not expanding to <unknown>, it is simply displaying %UserDisplayName% in the final file. I am also not getting any kind of an error message. %UserName% expands as expected. I am using a local account and it may be worth noting in my case the display name is the same as the username. I am using the extension with a C/C++ console app.

Here is my projectname.sln.licenseheader file:

extensions: .c .h
/*
 * Filename: %FileName%
 * Author(s): %UserDisplayName% (%UserName%@example.com)
 * Description: Short description of file
 * License: MIT (https://spdx.org/licenses/MIT.html)
*/

And here is the header it generates:

/*
 * Filename: ceesort.c
 * Author(s): %UserDisplayName% (Roland@example.com)
 * Description: Short description of file
 * License: MIT (https://spdx.org/licenses/MIT.html)
*/

System info

Software

Windows 10 Enterprise LTSC 2021 (21H2) (Fully updated) Visual Studio 2022 Community Edition Version 17.2.2 (Latest)

Hardware

CPU: Ryzen 5 3600 @ 3.6Ghz RAM: Corsair 16GB (2x8GB) @ 3200Mhz CL14 GPU: AMD RX 5700 Storage: 2TB NVME SSD (PCIe 3), 2TB SATA HDD @ 7200RPM

I am currently just using %UserName% as a workaround. Any help on this would be appreciated 😀.