The following function adds a user to the IIS_WPG group using the ntrights.exe utility by Microsoft. Note that in order for this function to work you have to have the ntrights utility downloaded. To download it check Microsoft’s wensite:
- Ntrights Utility Downloads
- Ntrights Command
- Ntrights Utility Download Software
- Ntrights Utility Download Windows 10
http://www.microsoft.com/downloads/details.aspx?FamilyID=9D467A69-57FF-4AE7-96EE-B18C4790CFFD&displaylang=en
public static void AddUserToWPG(string currentFolderPath, string user)
{
try
{
Process process = new Process();
//run the script
process.StartInfo.FileName = System.Environment.SystemDirectory + @'net.exe';
process.StartInfo.Arguments = string.Format(' localgroup '{0}' {1} /add', wpgGroup, user);
process.StartInfo.CreateNoWindow = true;
process.StartInfo.UseShellExecute = true;
process.Start();
process.WaitForExit();
process.StartInfo.FileName = Path.Combine(currentFolderPath, 'ntrights.exe');
process.StartInfo.Arguments = string.Format(' +r 'seTcbPrivilege' -u '{0}', user);
process.StartInfo.CreateNoWindow = true;
process.StartInfo.UseShellExecute = true;
process.Start();
process.WaitForExit();
}
catch
{
throw newException('your message');
}
- The answer is calling the utility NTRIGHTS.EXE. This is the Windows command-line utility for administrating rights for users. So, first you need to acquire the utility. It comes from the Windows Resource Kit. It is not installed as part of Windows, so you will need to download it and install it. After that, you have the utility.
- Download at Microsoft.com. Windows Server 2003 Resource Kit Tools; Name. (Process Status Utility) 33792: ntrights.exe- 18:06:06: Application (Windows.
- This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
}
Okay, I downloaded the ntrights utility from here: Download: Windows Server 2003 Resource Kit Tools - Microsoft Download Center - Download Details I used it as follows: C: windows system32ntrights -u Kitchen +r SeRemoteInteractiveLogonRight.
-->By Mark Russinovich
Published: October 15, 2020
Download AccessChk(957 KB)
Run now from Sysinternals Live.
Introduction
As a part of ensuring that they've created a secure environment Windowsadministrators often need to know what kind of accesses specific usersor groups have to resources including files, directories, Registry keys,global objects and Windows services. AccessChk quickly answers thesequestions with an intuitive interface and output.
Installation
AccessChk is a console program. Copy AccessChk onto your executablepath. Typing 'accesschk' displays its usage syntax.
Using AccessChk
Usage: accesschk [-s][-e][-u][-r][-w][-n][-v]-[f<account>,...][[-a]|[-k]|[-p [-f] [-t]]|[-h][-o[-t <object type>]][-c]|[-d]] [[-l[-i]]|[username]] <file, directory, registry key, process,service, object>
Parameter | Description |
---|---|
-a | Name is a Windows account right. Specify '*' as the name to show all rights assigned to a user. Note that when you specify a specific right, only groups and accounts directly assigned to the right are displayed. |
-c | Name is a Windows Service, e.g. ssdpsrv. Specify '*' as the name to show all services and 'scmanager' to check the security of the Service Control Manager. |
-d | Only process directories or top-level keys |
-e | Only show explicitly set-Integrity Levels (Windows Vista and higher only) |
-f | If following -p, shows full process token information including groups and privileges. Otherwise is a list of comma-separated accounts to filter from the output. |
-h | Name is a file or printer share. Specify '*' as the name to show all shares. |
-i | Ignore objects with only inherited ACEs when dumping full access control lists. |
-k | Name is a Registry key, e.g. hklmsoftware |
-l | Show full security descriptor. Add -i to ignore inherited ACEs. |
-n | Show only objects that have no access |
-o | Name is an object in the Object Manager namespace (default is root). To view the contents of a directory, specify the name with a trailing backslash or add -s. Add -t and an object type (e.g. section) to see only objects of a specific type. |
-p | Name is a process name or PID, e.g. cmd.exe (specify '*' as the name to show all processes). Add -f to show full process token information, including groups and privileges. Add -t to show threads. |
-q | Omit Banner |
-r | Show only objects that have read access |
-s | Recurse |
-t | Object type filter, e.g. 'section' |
-u | Suppress errors |
-v | Verbose (includes Windows Vista Integrity Level) |
-w | Show only objects that have write access |
If you specify a user or group name and path, AccessChk will report theeffective permissions for that account; otherwise it will show theeffective access for accounts referenced in the security descriptor.
By default, the path name is interpreted as a file system path (use the'pipe' prefix to specify a named pipe path). For each object,AccessChk prints R if the account has read access, W for write access,and nothing if it has neither. The -v switch has AccessChk dump thespecific accesses granted to an account.
Examples
The following command reports the accesses that the Power Users accounthas to files and directories in WindowsSystem32:
accesschk 'power users' c:windowssystem32
This command shows which Windows services members of the Users grouphave write access to:
accesschk users -cw *
Ntrights Utility Downloads
To see what Registry keys under HKLMCurrentUser a specific account hasno access to:
Ntrights Command
accesschk -kns austinmruss hklmsoftware
To see the security on the HKLMSoftware key:
accesschk -k hklmsoftware
To see all files under UsersMark on Vista that have an explicitintegrity level:
Ntrights Utility Download Software
accesschk -e -s c:usersmark
To see all global objects that Everyone can modify:
accesschk -wuo everyone basednamedobjects
Ntrights Utility Download Windows 10
Download AccessChk(957 KB)
Run now from Sysinternals Live.