Beispiel #1
0
        /// <summary>
        /// Maps a network share to the specfied drive. Using credentials. Throws Win32Exception on error.
        /// </summary>
        /// <param name="drive">Drive letter to map networkshare to. </param>
        /// <param name="sharePath">Path to the network share.</param>
        /// <param name="persistant">Whether or not to reconnect the drive on logon</param>
        /// <param name="username">Username to use</param>
        /// <param name="password">Password that matches username</param>
        /// <param name="saveLogin">Whether or not to save the username and password</param>
        public static void ConnectDrive(string drive, string sharePath, bool persistant, string username, string password, bool saveLogin)
        {
            NETRESOURCE nr = new NETRESOURCE();

            nr.Type       = RESOURCETYPE.DISK;
            nr.LocalName  = drive;
            nr.RemoteName = sharePath;
            ShareFlags flags = ShareFlags.None;

            if (persistant)
            {
                flags |= ShareFlags.RestoreOnLogon;
            }
            if (saveLogin)
            {
                flags |= ShareFlags.SaveCredentials;
            }

            int i = WNetAddConnection2A(ref nr, username, password, flags);

            if (i > 0)
            {
                throw new System.ComponentModel.Win32Exception(i);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Returns a copy with the specified flags.
        /// </summary>
        public SharedFolder WithFlags(ShareFlags flags)
        {
            SoapData newData = _data;

            newData.flags = flags;
            return(new SharedFolder(newData));
        }
Beispiel #3
0
 public TreeConnectResponse(byte[] buffer, int offset) : base(buffer, offset)
 {
     StructureSize = LittleEndianConverter.ToUInt16(buffer, offset + SMB2Header.Length + 0);
     ShareType     = (ShareType)ByteReader.ReadByte(buffer, offset + SMB2Header.Length + 2);
     Reserved      = ByteReader.ReadByte(buffer, offset + SMB2Header.Length + 3);
     ShareFlags    = (ShareFlags)LittleEndianConverter.ToUInt32(buffer, offset + SMB2Header.Length + 4);
     Capabilities  = (ShareCapabilities)LittleEndianConverter.ToUInt32(buffer, offset + SMB2Header.Length + 8);
     MaximalAccess = new AccessMask(buffer, offset + SMB2Header.Length + 12);
 }
Beispiel #4
0
 private static extern int WNetCancelConnection2A(string psName, ShareFlags piFlags, bool pfForce);
Beispiel #5
0
 private static extern int WNetAddConnection2A(ref NETRESOURCE pstNetRes, string psPassword, string psUsername, ShareFlags piFlags);
				private void SubroutinesCopyOnWrite()
				{
					if ((flags & ShareFlags.Subroutines) != 0)
					{
						flags &= ~ShareFlags.Subroutines;
						subroutines = CopySubroutines(subroutines);
					}
				}
				private void LocalsCopyOnWrite()
				{
					if ((flags & ShareFlags.Locals) != 0)
					{
						flags &= ~ShareFlags.Locals;
						locals = (SimpleType[])locals.Clone();
					}
				}
				private void StackCopyOnWrite()
				{
					if ((flags & ShareFlags.Stack) != 0)
					{
						flags &= ~ShareFlags.Stack;
						stack = (SimpleType[])stack.Clone();
					}
				}
				internal InstructionState(int maxLocals, int maxStack)
				{
					this.flags = ShareFlags.None;
					this.stack = new SimpleType[maxStack];
					this.stackEnd = maxStack;
					this.locals = new SimpleType[maxLocals];
				}
				private InstructionState(SimpleType[] stack, int stackSize, int stackEnd, SimpleType[] locals, List<Subroutine> subroutines, int callsites)
				{
					this.flags = ShareFlags.All;
					this.stack = stack;
					this.stackSize = stackSize;
					this.stackEnd = stackEnd;
					this.locals = locals;
					this.subroutines = subroutines;
					this.callsites = callsites;
				}