I'm developing a visual studio 2015 extension and I'm looking to get the identity of the user who's logged into the IDE (different to the user logged in to windows, or running devenv).
I can't figure out where (or if) I can get that information. It doesn't appear to be in the DTE object anywhere and googling around hasn't helped.
Just the username
string username = System.Environment.UserName;
or
string adName = System.Environment.UserDomainName;
Full UserPrinciple
System.DirectoryServices.AccountManagement.UserPrincipal.Current
Most the normal .net methods for getting users from system or globals should work. All the AD namespaces (System.DirectoryServices) will also work as usual.
Also this regkey gets set at vs startup with the interactive user.
Code:
C#
General:
in header / above namespace
MVC: Not sure about earlier version but 3 - 5 not required
using System.Security.Principal
function, property etc
string userid= User.Identity.Name.toString()
Related
I want to automatically create different MSIX packages/installers for the same MAUI app, so that each one runs a specific code snippet according to a flag parameter.
The user does not have to interact with the app. An installer per flag value has to be created, an once the app is installed and the user double clicks the app icon, the specific piece of code has to be run.
So far, I've tried without success the following approach, trying to create a script that passes the possible values of the flag as installation parameters using the app installer and a protocol, and then trying to publish the different packages in a local path.
I would like to know whether that's feasible or there may be any other approach to get it done.
You can check this comment about .NET MAUI Windows target publishing/archiving.
In the article, the right way to set the MSIX is that you had to create a self-signed certificate and then You could add a couple of extra parameters to also add the sign the MSIX and then trust that cert manually.
I am currently working on a Kiosk for my company, the point for me is to create a powershell script that will create a user and directly assign it as a Kiosk user with Microsoft Edge Chromium. It works fine with the windows settings but thats not how we need to make it. But when I want to make the command with powershell
Set-AssignedAccess -AUMID "MSEdge" -UserSID "USERSID"
When i do it this way I get this error :
New-CimInstance : One or multiple parameter values passed to the method are not valid.
So I managed to get another AUMID which is : Microsoft.MicrosoftEdge.Stable_8wekyb3d8bbwe!App
The command is a success after that but in the end when I connect to the Kiosk user it keeps on blinking loading blue screen and never pops out Microsoft Edge.
Does someone knows about this ?
Thank you.
Try using this AUMID Microsoft.MicrosoftEdge_8wekyb3d8bbwe!MicrosoftEdge.
This works for Windows Versions below 21H2.
I cannot help you at this time with the version above 21H2.
I'm playing around with a web application using the above and visual studio 2016 community. I've pretty much still got the default project using Individual User Account as the authentication. So it's built all the views and models around authentication and I can register accounts and log in. I'm now wanting to add some attributes to the default and running into some unknowns.
First question is about writing some non-default attributes. I've looked into how it's writing the default attributes (email and phone) and there are actually methods in the UserManager library class to update these attributes
public virtual Task<IdentityResult> SetEmailAsync(TUser user, string email);
and
public virtual Task<IdentityResult> SetPhoneNumberAsync(TUser user, string phoneNumber);
Obviously I can't add methods for my own attributes like SetTagLineAsync... because this is a library class. I found it a little strange that they have such specific methods in a library but anyway I have the user object in context in my controller (which you can see above in the virtual methods) and I think I should be able to just update that object and call this method
public virtual Task<IdentityResult> UpdateAsync(TUser user);
And it'll update the user in the database to use the attributes I've set on the user. But this leads into my second question, because I'm not certain how this works yet I would want to try the above method and then go check in the database if it did update the attribute I wanted.
Second question: How do I view the projects database? There is obviously a database that was created with the project template and it is persistent because if I run the web app and register, when I run it again I can log in as that user. When I make a change to the ApplicationUser class I also have to add a migration and update the database through package manager console. I can see in my app settings
"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet-MyApp-3B07911E-A6DD-4B3E-A533-57B04E37B791;Trusted_Connection=True;MultipleActiveResultSets=true"
I don't have SQL server installed if that matters, just whatever sql stuff was installed with VS. In other projects i just go to Server Explorer and my database appears under Data Connections. I've tried to add the data connection but when I do, I add the server name (localdb) ā i also tried without the brackets ā and then when I try to select a database name it throws connection errors. I've also tried doing this while the webapp is open by disconnecting the debugger and trying the same process in case it only exists while it's running but same thing. Any ideas?
Obviously I can't add methods for my own attributes like SetTagLineAsync...
You can add your own method(s) inheriting from UserManager class.
UpdateAsync vs. SetXXXAsync methods
SetXXXAsync methods are more complex and have additional logic inside. For example SetEmailAsync and SetPhoneAsync are not only setting Email and Phone property/column, but also EmailConfirmed = false and PhoneConfirmed = false. Both are also setting new security stamp that is used to indicate, if user changed profile. In that case he/she needs to perform new login on (other) devices(rejecting cookies that was set before the change happened). Which is useful security feature. It will be really bad if you change your password, but cookies set with old one will still work.
public virtual async Task<IdentityResult> SetPhoneNumberAsync(TUser user, string phoneNumber)
{
ThrowIfDisposed();
var store = GetPhoneNumberStore();
if (user == null)
{
throw new ArgumentNullException(nameof(user));
}
await store.SetPhoneNumberAsync(user, phoneNumber, CancellationToken);
await store.SetPhoneNumberConfirmedAsync(user, false, CancellationToken);
await UpdateSecurityStampInternal(user);
return await UpdateUserAsync(user);
}
How do I view the projects database?
You have to use (localdb)\MSSQLLocalDB as server name.
LocalDb is development database and may be installed during Visual Studio installation.
Related links:
Introduction to Identity on ASP.NET Core
UserManager class (source code)
What is ASP.NET Identity's IUserSecurityStampStore interface?
How to connect to LocalDB in Visual Studio Server Explorer?
Introducing LocalDB, an improved SQL Express
Advice Nsis ā windows7
I have two users on the same computer (Admin and standard), I will be running my nsis installer when logged in to the standard user. My problem is that I need to create shortcuts on both desktops!!
Example
Standard User - Desktop
- Shortcut 1
- Shortcut 2
- Shortcut 3
Admin User - Desktop
- Shortcut 2
- Shortcut 4
Iām new to nsis- I have managed to create the Shortcut on the standard user account - If it helps I know the admin username and password.
NSIS - Desktop Shortcut For All Users
I saw this link but it does not seem to be working
When I try
CreateShortCut "${ProfilePathAllUsers}\Desktop\simpleApp.lnk" "$INSTDIR\ApplicationsLocation\ Applications.simpleApp.Host.exe"
I fear I may be going in the wrong direction-
Im also using Unicode Nsis
Any Advice will be welcome - Thank you
You cannot write to another users profile without administrator rights so make sure you are elevated.
Creating a shortcut for another user is wrong IMHO. If you want to create a shortcut for all users you can do:
; This code assumes you are elevated...
SetShellVarContext all
CreateShortcut "$desktop\myapp.lnk" "$instdir\myapp.exe"
Knowing the username/password would indeed help if you really wanted to do it for a single user; you would have to call LogonUser + SHGetFolderPath with the system plugin to get the path (Or the code you linked to but that uses undocumented stuff).
I am writing some Selenium RC tests using the perl library WWW::Selenium. At the beginning of the test I need to login to a web form using my username and password.
I noticed that my password is displayed in the Selenium Remote Control "Command History" window as type(password, secret).
Is there any way to suppress the display of the password? Maybe there is a command other than type I can use?
Unfortunately no. You could go into the Selenium core and change it to show ******* when it finds a field named password.
Beware though that this could make life difficult when debugging
I guess we can do this using native methods support.
Think logically every native methods in selenium will be sent to the operating system not to the browser.
So if you use any of the native methods, the flow is like this:
Client Program ----> Selenium RC server ----> to the operating system (in Java this is done using Robot Class)
But all the other non-native methods flow is like this:
Client Program ----> Selenium RC server ----> to the Browser
So, the Command History window operates at the Browser level and the native methods will not reach there.
Here is the code:
selenium.focus("locator");
selenium.keyPressNative("key code"); // this will not be shown in command history
Here the key code is only for one character and if you want string (more than one character), we should rely on our client program to implement the logic.
I have given that code in my previous answers to other posts. If you need it personalised post our exact requirement so that I can give that code tailored to your need.