Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feature: [MS-SRVS] NetrShareAdd() function #313

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions ProtoSDK/MS-SRVS/SrvsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,55 @@ public void UnBind()
}
}

/// <summary>
/// The NetrShareAdd method creates a new share on the specified server.
/// </summary>
/// <param name="serverName">A string that identifies the server. If this parameter is NULL, the local computer is used.</param>
/// <param name="Level">An enumeration representing the level of information provided in the InfoStruct parameter.</param>
/// <param name="InfoStruct">A structure containing information about the share being added.</param>
/// <param name="ParmErr">A pointer to a value that receives error information if the method fails. If the method returns a nonzero error code,
/// ParmErr receives additional error details; otherwise, it remains unchanged.</param>
/// <returns>The method returns 0x00000000 (NERR_Success) to indicate success; otherwise, it returns a nonzero error code.</returns>
public uint NetrShareAdd(
string ServerName,
SHARE_ENUM_STRUCT_LEVEL Level,
SHARE_INFO InfoStruct,
ref uint? ParmErr)
{
/* NET_API_STATUS NetrShareAdd(
[in, string, unique] SRVSVC_HANDLE ServerName,
[in] DWORD Level,
[in, switch_is(Level)] LPSHARE_INFO InfoStruct,
[in, out, unique] DWORD* ParmErr
);
*/

Int3264[] paramList;
uint retVal = 0;

using (SafeIntPtr pServerName = Marshal.StringToHGlobalUni(ServerName),
pShareInfo = TypeMarshal.ToIntPtr(InfoStruct, Level, null, null),
pParmErr = TypeMarshal.ToIntPtr(ParmErr))
{
paramList = new Int3264[]{
pServerName,
(uint)Level,
pShareInfo, // out value
pParmErr,
IntPtr.Zero // return value
};
using (RpceInt3264Collection outParamList = RpceCall(paramList, (ushort)SRVS_OPNUM.NetrShareAdd))
{
retVal = outParamList[paramList.Length - 1].ToUInt32();
if (retVal == (uint)Win32ErrorCode_32.ERROR_INVALID_PARAMETER)
{
ParmErr = TypeMarshal.ToNullableStruct<uint>(outParamList[4]);
}
}
}
return retVal;
}

/// <summary>
/// The NetrShareEnum method retrieves information about each shared resource on a server.
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions ProtoSDK/MS-SRVS/SrvsMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace Microsoft.Protocols.TestTools.StackSdk.Srvs
{
public enum SRVS_OPNUM : ushort
{
NetrShareAdd = 14,
NetrShareEnum = 15,
NetrShareGetInfo = 16,
NetrShareSetInfo = 17
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ However, each test suite provides users with a useful indication of interoperabi
* **SMBD Server Test Suite**. It is designed to test the implementations of SMB2&3 direct (RDMA) protocol, as specified in [MS-SMBD] and [MS-SMB2].
* **Branch Cache Test Suite**. It is designed to test the implementations of [MS-PCCRTP], [MS-PCCRR], [MS-PCHC] and [MS-PCCRC] protocol.
* **AZOD Test Suite**. It is designed to test the implementations of [MS-AZOD] protocol.
* **ADFamily Test Suite**. It is designed to test the implementations of the Active Directory protocols including [MS-ADA1], [MS-ADA2], [MS-ADA3], [MS-ADLS], [MS-ADSC], [MS-ADTS], [MS-APDS], [MS-DRSR], [MS-FRS2], [MS-LSAD], [MS-LSAT], [MS-SAMR] and [MS-NRPC].
* **ADFamily Test Suite**. It is designed to test the implementations of the Active Directory protocols including [MS-ADA1], [MS-ADA2], [MS-ADA3], [MS-ADLS], [MS-ADSC], [MS-ADTS], [MS-APDS], [MS-DRSR], [MS-FRS2], [MS-LSAD], [MS-LSAT], [MS-SAMR], [MS-NRPC] and [MS-SRVS].
* **ADFSPIP Client Test Suite**. It is designed to test the implementations of ADFS Proxy and Web Application Proxy integration, as described in [MS-ADFSPIP].
* **ADOD Test Suite**. It is designed to test the implementations of [MS-ADOD] protocol.

Expand Down