Minor code refactoring: Use a single ImpersonationLevel enumeration instead of one for SMB1 and another for SMB2

This commit is contained in:
Tal Aloni 2017-09-30 10:59:40 +03:00
parent de4ab95d80
commit 42f00b4740
5 changed files with 17 additions and 28 deletions

View file

@ -33,7 +33,7 @@ namespace SMBLibrary.Client
request.ShareAccess = shareAccess;
request.CreateDisposition = createDisposition;
request.CreateOptions = createOptions;
request.ImpersonationLevel = ImpersonationLevel.SEC_IMPERSONATE;
request.ImpersonationLevel = ImpersonationLevel.Impersonation;
TrySendMessage(request);
SMB1Message reply = m_client.WaitForMessage(CommandName.SMB_COM_NT_CREATE_ANDX);

View file

@ -0,0 +1,15 @@
namespace SMBLibrary
{
/// <summary>
/// https://msdn.microsoft.com/en-us/library/windows/desktop/aa379572(v=vs.85).aspx
/// https://msdn.microsoft.com/en-us/library/windows/hardware/ff556631(v=vs.85).aspx
/// </summary>
public enum ImpersonationLevel : uint
{
Anonymous = 0x00000000, // SECURITY_ANONYMOUS
Identification = 0x00000001, // SECURITY_IDENTIFICATION
Impersonation = 0x00000002, // SECURITY_IMPERSONATION
Delegation = 0x00000003, // SECURITY_DELEGATION (This impersonation level is supported starting with Windows 2000)
}
}

View file

@ -1,11 +0,0 @@
namespace SMBLibrary.SMB1
{
public enum ImpersonationLevel : uint
{
SEC_ANONYMOUS = 0x00,
SEC_IDENTIFY = 0x01,
SEC_IMPERSONATE = 0x02,
SECURITY_DELEGATION = 0x03, // SMB 1.0 addition
}
}

View file

@ -1,14 +0,0 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace SMBLibrary.SMB2
{
public enum ImpersonationLevel : uint
{
Anonymous = 0x00000000,
Identification = 0x00000001,
Impersonation = 0x00000002,
Delegate = 0x00000003,
}
}

View file

@ -121,6 +121,7 @@
<Compile Include="NTFileStore\Enums\NtCreateFile\CreateOptions.cs" />
<Compile Include="NTFileStore\Enums\NtCreateFile\FileStatus.cs" />
<Compile Include="NTFileStore\Enums\NtCreateFile\ShareAccess.cs" />
<Compile Include="NTFileStore\Enums\SecurityInformation\ImpersonationLevel.cs" />
<Compile Include="NTFileStore\Enums\SecurityInformation\SecurityInformation.cs" />
<Compile Include="NTFileStore\INTFileStore.cs" />
<Compile Include="NTFileStore\NamedPipeStore.cs" />
@ -389,7 +390,6 @@
<Compile Include="SMB1\Enums\Negotiate\Capabilities.cs" />
<Compile Include="SMB1\Enums\Negotiate\SecurityMode.cs" />
<Compile Include="SMB1\Enums\NTCreate\FileStatusFlags.cs" />
<Compile Include="SMB1\Enums\NTCreate\ImpersonationLevel.cs" />
<Compile Include="SMB1\Enums\NTCreate\NTCreateFlags.cs" />
<Compile Include="SMB1\Enums\NTCreate\OpLockLevel.cs" />
<Compile Include="SMB1\Enums\NTCreate\SecurityFlags.cs" />
@ -551,7 +551,6 @@
<Compile Include="SMB2\Enums\Close\CloseFlags.cs" />
<Compile Include="SMB2\Enums\Create\CreateAction.cs" />
<Compile Include="SMB2\Enums\Create\CreateResponseFlags.cs" />
<Compile Include="SMB2\Enums\Create\ImpersonationLevel.cs" />
<Compile Include="SMB2\Enums\Create\OplockLevel.cs" />
<Compile Include="SMB2\Enums\InfoType.cs" />
<Compile Include="SMB2\Enums\IOCtl\IOCtlRequestFlags.cs" />