Answer the question
In order to leave comments, you need to log in
Find out current user's SID and replace .xml content?
Hello. You need to create a console application in C#.
1. Find out the user's SID, in this form S-1-5-21-2303912444-598105561-2700407050-1001
2. Replace the word "C-han-ge-me" in the desktop.xml file with the found SID.
desktop.xml file
<Principals>
<Principal id="Author">
<UserId>C-han-ge-me</UserId>
<LogonType>InteractiveToken</LogonType>
<RunLevel>LeastPrivilege</RunLevel>
</Principal>
</Principals>
Answer the question
In order to leave comments, you need to log in
Replaces the word "C-han-ge-me" with the word "strUser". but you need to replace it with a value like S-1-5-21-2303912444-598105561-2700407050-1001
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Security.Principal;
using System.Web.Security;
using System.IO;
namespace ConsoleApp13
{
class Program
{
static void Main(string[] args)
{
string strUser = System.Security.Principal.WindowsIdentity.GetCurrent().User.ToString();
File.WriteAllText("desktop.xml", File.ReadAllText("desktop.xml").Replace("C-han-ge-me", "strUser"));
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question