本文整理汇总了C#中ShareType类的典型用法代码示例。如果您正苦于以下问题:C# ShareType类的具体用法?C# ShareType怎么用?C# ShareType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ShareType类属于命名空间,在下文中一共展示了ShareType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SmbFile
/// <summary>
/// SMB file constructor.
/// </summary>
/// <param name="shareType">The type of resource the client intends to access.</param>
/// <param name="name">The name of the file.</param>
/// <param name="treeId">This is used to indicate the share that the client is accessing.</param>
/// <param name="accessRights">Access right.</param>
public SmbFile(ShareType shareType, string name, int treeId, int accessRights)
{
this.shareType = shareType;
this.name = name;
this.treeId = treeId;
this.accessRights = accessRights;
}
示例2: SmbMailslot
public SmbMailslot(ShareType shareType, string pipeName, int treeId)
{
this.shareType = shareType;
this.pipeName = pipeName;
this.treeId = treeId;
this.avaiableDataBytes = 0;
}
示例3: Share
public Share(string server, string netName, ShareType shareType)
{
if(ShareType.Special == shareType && "IPC$" == netName)
{
shareType |= ShareType.IPC;
}
_shareServer = server;
_networkName = netName;
_shareType = shareType;
}
示例4: ShareInfo
public ShareInfo(string serverName, string netName, string path, ShareType shareType, string remark)
{
if (shareType == ShareType.Special && netName == "IPC$")
{
shareType |= ShareType.IPC;
}
_serverName = serverName;
_netName = netName;
_path = path;
_shareType = shareType;
_remark = remark;
}
示例5: Share
/// <summary>
/// Constructor
/// </summary>
/// <param name="server">The server.</param>
/// <param name="netName">Name of the net.</param>
/// <param name="path">The path.</param>
/// <param name="shareType">Type of the share.</param>
/// <param name="remark">The remark.</param>
public Share(string server, string netName, string path, ShareType shareType, string remark)
{
if (ShareType.Special == shareType && "IPC$" == netName)
{
shareType |= ShareType.IPC;
}
_server = server;
_netName = netName;
_path = path;
_shareType = shareType;
_remark = remark;
}
示例6: ShareMonitor
internal ShareMonitor(string shareName, string hostName, string userName)
{
_share = shareName.Trim();
_host = hostName.Trim();
_user = userName.Trim();
if (_share.Equals(string.Empty))
{
if (_host.Equals(string.Empty))
{
if (_user.Equals(string.Empty))
{
MonitoringType = ShareType.Undefined;
}
else
{
MonitoringType = ShareType.UserOnly;
}
}
else if (_user.Equals(string.Empty))
{
MonitoringType = ShareType.HostOnly;
}
else
{
MonitoringType = ShareType.UserFromHostConnected;
}
}
else if (_host.Equals(string.Empty))
{
if (_user.Equals(string.Empty))
{
MonitoringType = ShareType.ShareOnly;
}
else
{
MonitoringType = ShareType.UserUsingShare;
}
}
else if (_user.Equals(string.Empty))
{
MonitoringType = ShareType.HostUsingShare;
}
else
{
MonitoringType = ShareType.UserFromHostUsingShare;
}
Log.Debug("ShareMonitor: Monitor user '{0}' from host '{1}' on share '{2}' Type '{3}'", _user, _host, _share,
MonitoringType);
}
示例7: ShareMonitor
internal ShareMonitor(string shareName, string clientName, string userName)
{
_share = shareName.Trim();
_client = clientName.Trim();
_user = userName.Trim();
if (_share.Equals(string.Empty))
{
if (_client.Equals(string.Empty))
{
if (_user.Equals(string.Empty))
{
MonitoringType = ShareType.Any;
}
else
{
MonitoringType = ShareType.UserOnly;
}
}
else if (_user.Equals(string.Empty))
{
MonitoringType = ShareType.ClientOnly;
}
else
{
MonitoringType = ShareType.UserFromClientConnected;
}
}
else if (_client.Equals(string.Empty))
{
if (_user.Equals(string.Empty))
{
MonitoringType = ShareType.ShareOnly;
}
else
{
MonitoringType = ShareType.UserUsingShare;
}
}
else if (_user.Equals(string.Empty))
{
MonitoringType = ShareType.ClientUsingShare;
}
else
{
MonitoringType = ShareType.UserFromClientUsingShare;
}
Log.Debug("ActiveSharesHandler: Monitor connections to share '{0}' from client '{1}' by user '{2}' (Type '{3}')", _share, _client, _user, MonitoringType);
}
示例8: GetUserFavorites
public override ShareCollection GetUserFavorites(int favOwnerID, ShareType? favType, int pageNumber, int pageSize, ref int? totalCount)
{
using (SqlQuery query = new SqlQuery())
{
query.Pager.TableName = "[bx_SharesView]";
query.Pager.SortField = "[ShareID]";
query.Pager.IsDesc = true;
query.Pager.PageNumber = pageNumber;
query.Pager.PageSize = pageSize;
query.Pager.TotalRecords = totalCount;
query.Pager.SelectCount = true;
SqlConditionBuilder cb = new SqlConditionBuilder(SqlConditionStart.None);
cb.Append("[UserID] = @UserID");
query.CreateParameter<int>("@UserID", favOwnerID, SqlDbType.Int);
if (favType.HasValue && favType.Value != ShareType.All)
{
cb.Append("[Type] = @Type");
query.CreateParameter<ShareType>("@Type", favType.Value, SqlDbType.TinyInt);
}
cb.Append("[PrivacyType] = 2");
query.Pager.Condition = cb.ToString();
using (XSqlDataReader reader = query.ExecuteReader())
{
ShareCollection shares = new ShareCollection(reader);
if (reader.NextResult())
{
if (totalCount == null && reader.Read())
{
totalCount = reader.Get<int>(0);
}
shares.TotalRecords = totalCount.GetValueOrDefault();
}
return shares;
}
}
}
示例9: ToNetworkShareType
/// <summary>
/// To the type of the network share.
/// </summary>
/// <param name="shareType">Type of the share.</param>
/// <returns>NetworkShareType.</returns>
/// <exception cref="System.ArgumentException">Unknown share type</exception>
private NetworkShareType ToNetworkShareType(ShareType shareType)
{
if (shareType.HasFlag(ShareType.Special))
{
return NetworkShareType.Special;
}
if (shareType.HasFlag(ShareType.Device))
{
return NetworkShareType.Device;
}
if (shareType.HasFlag(ShareType.Disk))
{
return NetworkShareType.Disk;
}
if (shareType.HasFlag(ShareType.IPC))
{
return NetworkShareType.Ipc;
}
if (shareType.HasFlag(ShareType.Printer))
{
return NetworkShareType.Printer;
}
throw new ArgumentException("Unknown share type");
}
示例10: UpdateTreeConnectResponse
/// <summary>
/// Update SMB_COM_TREE_CONNECT_ANDX response.
/// </summary>
/// <param name="connection">It represents the SMB connection.</param>
/// <param name="messageId">This is used to associate a response with a request.</param>
/// <param name="treeId">This is used to indicate the share that the client is accessing.</param>
/// <param name="shareType">The type of resource the client intends to access.</param>
/// <param name="sessionId">
/// Set this value to 0 to request a new session setup, or set this value to a previously established session
/// identifier to request the re-authentication of an existing session.
/// </param>
public static void UpdateTreeConnectResponse(
SmbConnection connection,
int messageId,
int sessionId,
int treeId,
ShareType shareType)
{
TreeConnectRequest request = (TreeConnectRequest)connection.sentRequest[messageId];
connection.treeConnectList.Add(
treeId,
new SmbTree(treeId, new SmbShare(request.shareName, shareType), sessionId));
switch (shareType)
{
case ShareType.Disk:
Parameter.shareFileNames.Remove(request.shareName);
break;
case ShareType.NamedPipe:
Parameter.sharePipeNames.Remove(request.shareName);
break;
case ShareType.Printer:
Parameter.sharePrinterNames.Remove(request.shareName);
break;
case ShareType.CommunicationDevice:
Parameter.shareDeviceNames.Remove(request.shareName);
break;
default:
break;
}
connection.SutSendSequenceNumber.Remove(messageId);
connection.SutSendSequenceNumber.Remove(messageId);
connection.sentRequest.Remove(messageId);
connection.SutNextReceiveSequenceNumber++;
connection.treeId++;
}
示例11: GetShareInfo
public static List<ShareInfo> GetShareInfo(ShareType shareType)
{
IList<ShareType> shareTypeList = new List<ShareType>();
shareTypeList.Add(shareType);
return GetShareInfo(Environment.MachineName, shareTypeList);
}
示例12: VerifyMessageSystaxAccessMasksForPrinter
/// <summary>
/// Verify Access Masks.
/// </summary>
/// <param name="smbTreeConnectAndxPacket">Packets for SmbTreeConnectAndxPacket Response.</param>
/// <param name="shareType">To judge if the share type is the Printer</param>
private void VerifyMessageSystaxAccessMasksForPrinter(
SmbTreeConnectAndxResponsePacket smbTreeConnectAndxPacket,
ShareType shareType)
{
if (shareType == ShareType.Printer)
{
//
// The following statement code will be run only when debugging.
//
Site.Log.Add(LogEntryKind.Debug,
@"Verify MS-SMB_R109080");
//
// Verify MS-SMB requirement: MS-SMB_R109080.
//
bool isContainFILE_WRITE_DATA = (smbTreeConnectAndxPacket.SmbParameters.MaximalShareAccessRights &
(uint)CIFS.NtTransactDesiredAccess.FILE_WRITE_DATA) == (uint)CIFS.NtTransactDesiredAccess.FILE_WRITE_DATA;
bool isContainFile_APPEND_DATA = (smbTreeConnectAndxPacket.SmbParameters.MaximalShareAccessRights &
(uint)CIFS.NtTransactDesiredAccess.FILE_APPEND_DATA) == (uint)CIFS.NtTransactDesiredAccess.FILE_APPEND_DATA;
bool isContainGENERIC_WRITE = (smbTreeConnectAndxPacket.SmbParameters.MaximalShareAccessRights &
(uint)CIFS.NtTransactDesiredAccess.GENERIC_WRITE) == (uint)CIFS.NtTransactDesiredAccess.GENERIC_WRITE;
bool isContainValue = isContainFILE_WRITE_DATA || isContainFile_APPEND_DATA || isContainGENERIC_WRITE;
// If the value has at least one of the following: FILE_WRITE_DATA, FILE_APPEND_DATA, or GENERIC_WRITE,
// then the isContainValue equals true, this requirement is captured.
Site.CaptureRequirementIfIsTrue(
isContainValue,
109080,
"[In File_Pipe_Printer_Access_Mask]File_Pipe_Printer_Access_Mask (4 bytes): For a printer, the value MUST have at least one of the following: FILE_WRITE_DATA, FILE_APPEND_DATA, or GENERIC_WRITE.");
}
}
示例13: NtTransactCreateRequest
public static void NtTransactCreateRequest(
int messageId,
int sessionId,
int treeId,
[Domain("ImpersonationLevel")] int impersonationLevel,
[Domain("FileDomain")] string fileName,
ShareType shareType,
bool isSigned)
{
smbRequest = new NtTransactCreateRequest(
messageId,
sessionId,
treeId,
impersonationLevel,
fileName,
shareType,
isSigned);
Checker.CheckNtTransactCreateRequest(
smbConnection,
messageId,
sessionId,
treeId,
shareType,
isSigned,
fileName,
smbState);
Requirement.AssumeCaptured("Send NT_TRANSACT_CREATE request");
Update.UpdateNTTransactCreateRequest(smbConnection, smbRequest);
}
示例14: Share
/// <summary>
/// Constructor.
/// </summary>
/// <param name="server">Server of the new share.</param>
/// <param name="netName">Name of the new share.</param>
/// <param name="path">Local path of the new share.</param>
/// <param name="shareType">Type of the new share.</param>
/// <param name="remark">Comment of the new share.</param>
public Share(string server, string netName, string path, ShareType shareType, string remark)
{
if (ShareType.Special == shareType && "IPC$" == netName)
shareType |= ShareType.IPC;
if (server.StartsWith("\\\\"))
server = server.Substring(2);
_server = server;
_netName = netName;
_path = path;
_shareType = shareType;
_remark = remark;
}
示例15: NtTransactCreateRequest
public void NtTransactCreateRequest(
int messageId,
int sessionId,
int treeId,
[Domain("ImpersonationLevel")] int impersonationLevel,
[Domain("FileDomain")] string fileName,
ShareType shareType,
bool isSigned)
{
#region Create Packet
SmbNtCreateAndxRequestPacket smbPacket = new SmbNtCreateAndxRequestPacket();
ushort uid = (ushort)this.uId[(uint)sessionId];
ushort tid = (ushort)this.tId[(uint)treeId];
string shareName = string.Empty;
if (shareType == ShareType.NamedPipe)
{
if (SmbAdapter.isMessageModePipe)
{
shareName = Site.Properties["SutShareMessagePipe"];
}
else
{
shareName = Site.Properties["SutShareStreamPipe"];
}
}
else
{
if (fileName == Site.Properties["SutShareTest1"])
{
shareName = Site.Properties["SutShareTest1"];
}
else if (fileName == Site.Properties["SutShareTest2"])
{
shareName = Site.Properties["SutShareTest2"];
}
else if (fileName == Site.Properties["SutShareExistFile"])
{
shareName = Site.Properties["SutShareExistFile"];
}
else if (fileName.Contains("."))
{
shareName = fileName;
}
else
{
shareName = fileName;
}
}
this.openedFileName = shareName;
uint nTDesiredAccess = (uint)NamespaceCifs.NtTransactDesiredAccess.GENERIC_ALL;
NamespaceCifs.SMB_EXT_FILE_ATTR extFileAttributes = NamespaceCifs.SMB_EXT_FILE_ATTR.NONE;
NtTransactCreateOptions createOption = NtTransactCreateOptions.FILE_NON_DIRECTORY_FILE;
smbPacket = this.smbClientStack.CreateCreateRequest(
tid,
shareName,
(NamespaceCifs.NtTransactDesiredAccess)nTDesiredAccess,
extFileAttributes,
NamespaceCifs.NtTransactShareAccess.NONE,
NamespaceCifs.NtTransactCreateDisposition.FILE_OPEN_IF,
createOption,
(NamespaceCifs.NtTransactImpersonationLevel)impersonationLevel,
CreateFlags.NT_CREATE_REQUEST_OPLOCK);
if (isSigned)
{
NamespaceCifs.CifsClientPerConnection connection =
this.smbClientStack.Context.GetConnection(ConnectionId);
NamespaceCifs.CifsClientPerSession session = this.smbClientStack.Context.GetSession(ConnectionId, uid);
smbPacket.Sign(connection.ClientNextSendSequenceNumber, session.SessionKey);
}
#endregion
#region Send and Receive ExpectPacket
this.smbClientStack.SendPacket(smbPacket);
StackPacket response = this.smbClientStack.ExpectPacket(this.timeout);
NamespaceCifs.SmbPacket smbPacketResponse = (NamespaceCifs.SmbPacket)response;
this.QueryUidTable(smbPacketResponse);
this.QueryTidTable(smbPacketResponse);
VerifyTransport(smbPacketResponse);
VerifyCommonMessageSyntax(smbPacketResponse);
if (response.GetType() == typeof(SmbErrorResponsePacket))
{
SmbErrorResponsePacket smbErrorResponsePacket = response as SmbErrorResponsePacket;
NamespaceCifs.SmbHeader smbErrorHeader = smbErrorResponsePacket.SmbHeader;
this.ErrorResponse(smbErrorHeader.Mid + this.addMidMark, (MessageStatus)smbErrorHeader.Status);
}
//.........这里部分代码省略.........