TreeConnect() private method

private TreeConnect ( ServerMessageBlock andx, ServerMessageBlock andxResponse ) : void
andx ServerMessageBlock
andxResponse ServerMessageBlock
return void
Example #1
0
        /// <exception cref="SharpCifs.Smb.SmbException"></exception>
        public static void Logon(UniAddress dc, int port, NtlmPasswordAuthentication auth
                                 )
        {
            SmbTree tree = SmbTransport.GetSmbTransport(dc, port).GetSmbSession(auth).GetSmbTree
                               (LogonShare, null);

            if (LogonShare == null)
            {
                tree.TreeConnect(null, null);
            }
            else
            {
                Trans2FindFirst2         req  = new Trans2FindFirst2("\\", "*", SmbFile.AttrDirectory);
                Trans2FindFirst2Response resp = new Trans2FindFirst2Response();
                tree.Send(req, resp);
            }
        }
Example #2
0
        /// <exception cref="System.IO.IOException"></exception>
        internal virtual void DoConnect()
        {
            SmbTransport trans;
            UniAddress addr;
            addr = GetAddress();

            if (Tree != null && Tree.Session.transport.Address.Equals(addr))
            {
                trans = Tree.Session.transport;
            }
            else
            {
                trans = SmbTransport.GetSmbTransport(addr, Url.Port);
                Tree = trans.GetSmbSession(Auth).GetSmbTree(_share, null);
            }


            string hostName = GetServerWithDfs();
            if (_enableDfs)
            {
                Tree.InDomainDfs = Dfs.Resolve(hostName, Tree.Share, null, Auth) != null;
            }
            if (Tree.InDomainDfs)
            {
                Tree.ConnectionState = 2;
            }
            try
            {
                if (Log.Level >= 3)
                {
                    Log.WriteLine("doConnect: " + addr);
                }
                Tree.TreeConnect(null, null);
            }
            catch (SmbAuthException sae)
            {
                NtlmPasswordAuthentication a;
                SmbSession ssn;
                if (_share == null)
                {
                    // IPC$ - try "anonymous" credentials
                    ssn = trans.GetSmbSession(NtlmPasswordAuthentication.Null);
                    Tree = ssn.GetSmbTree(null, null);
                    Tree.TreeConnect(null, null);
                }
                else
                {
                    if ((a = NtlmAuthenticator.RequestNtlmPasswordAuthentication(Url.ToString(), sae)
                        ) != null)
                    {
                        Auth = a;
                        ssn = trans.GetSmbSession(Auth);
                        Tree = ssn.GetSmbTree(_share, null);
                        Tree.InDomainDfs = Dfs.Resolve(hostName, Tree.Share, null, Auth) != null;
                        if (Tree.InDomainDfs)
                        {
                            Tree.ConnectionState = 2;
                        }
                        Tree.TreeConnect(null, null);
                    }
                    else
                    {
                        if (Log.Level >= 1 && HasNextAddress())
                        {
                            Runtime.PrintStackTrace(sae, Log);
                        }
                        throw;
                    }
                }
            }
        }