Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than advapi32, prefix the name with the module name and a period.
The UserRights parameter is really an array of LSA_UNICODE_STRINGS
VB.Net Sample Code:
Private WinWorldSid As Integer = 1
Private POLICY_ALL_ACCESS As Integer = &HF0FFF
Private SECURITY_MAX_SID_SIZE As Integer = 68
Private SE_DENY_REMOTE_INTERACTIVE_LOGON_NAME As String = "SeDenyRemoteInteractiveLogonRight"
Private NT_STATUS_OBJECT_NAME_NOT_FOUND As Integer = &HC0000034
Private STATUS_NO_MORE_ENTRIES As Integer = &H8000001A
' Remove the Deny permission
Public Sub AllowTS(ByVal PC As String)
Dim ret, Access, sidsize As Integer
Dim SystemName, DenyTSRights As LSA_UNICODE_STRING
Dim ObjectAttr As LSA_OBJECT_ATTRIBUTES
Dim Policy, EveryoneSID As IntPtr
' build a well-known SID for "Everyone"
sidsize = SECURITY_MAX_SID_SIZE
EveryoneSID = Marshal.AllocHGlobal(sidsize)
If CreateWellKnownSid(WinWorldSid, IntPtr.Zero, EveryoneSID, sidsize) = False Then
ret = Marshal.GetLastWin32Error()
Throw New Win32Exception(ret)
End If
' setup the parameters for the LsaOpenPolicy API
ObjectAttr.Length = Marshal.SizeOf(ObjectAttr)
SystemName.Length = PC.Length * UnicodeEncoding.CharSize
SystemName.MaximumLength = (PC.Length + 1) * UnicodeEncoding.CharSize
SystemName.Buffer = Marshal.StringToHGlobalUni(PC)
Access = POLICY_ALL_ACCESS
' open a policy handle on the remote PC
ret = LsaOpenPolicy(SystemName, ObjectAttr, Access, Policy)
If ret <> 0 Then
Throw New Win32Exception(LsaNtStatusToWinError(ret))
End If
' clean up
Marshal.FreeHGlobal(SystemName.Buffer)
' Setup the input parameters for the LsaRemoveAccountRights API
DenyTSRights.Length = SE_DENY_REMOTE_INTERACTIVE_LOGON_NAME.Length * UnicodeEncoding.CharSize
DenyTSRights.MaximumLength = (SE_DENY_REMOTE_INTERACTIVE_LOGON_NAME.Length + 1) * UnicodeEncoding.CharSize
DenyTSRights.Buffer = Marshal.StringToHGlobalUni(SE_DENY_REMOTE_INTERACTIVE_LOGON_NAME)
' do it!
ret = LsaRemoveAccountRights(Policy, EveryoneSID, False, DenyTSRights, 1)
If ret <> 0 And ret <> NT_STATUS_OBJECT_NAME_NOT_FOUND Then
Marshal.FreeHGlobal(DenyTSRights.Buffer)
LsaClose(Policy)
Throw New Win32Exception(LsaNtStatusToWinError(ret))
End If
' clean up
Marshal.FreeHGlobal(DenyTSRights.Buffer)
LsaClose(Policy)
End Sub
The LsaRemoveAccountRights function removes one or more privileges from an account.
8/20/2007 7:53:59 AM - egray1@hot.rr.com-150.113.7.99
The SetLastError API
1/26/2016 3:27:33 AM - -124.148.167.58
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).