/// <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); } }
/// <exception cref="SharpCifs.Smb.SmbException"></exception> /// <exception cref="UnknownHostException"></exception> /// <exception cref="System.UriFormatException"></exception> internal virtual void DoFindFirstNext(List<object> list, bool files, string wildcard , int searchAttributes, ISmbFilenameFilter fnf, ISmbFileFilter ff) { SmbComTransaction req; Trans2FindFirst2Response resp; int sid; string path = GetUncPath0(); string p = Url.AbsolutePath; if (p.LastIndexOf('/') != (p.Length - 1)) { throw new SmbException(Url + " directory must end with '/'"); } req = new Trans2FindFirst2(path, wildcard, searchAttributes); resp = new Trans2FindFirst2Response(); if (Log.Level >= 3) { Log.WriteLine("doFindFirstNext: " + req.Path); } Send(req, resp); sid = resp.Sid; req = new Trans2FindNext2(sid, resp.ResumeKey, resp.LastName); resp.SubCommand = SmbComTransaction.Trans2FindNext2; for (; ; ) { for (int i = 0; i < resp.NumEntries; i++) { IFileEntry e = resp.Results[i]; string name = e.GetName(); if (name.Length < 3) { int h = name.GetHashCode(); if (h == HashDot || h == HashDotDot) { if (name.Equals(".") || name.Equals("..")) { continue; } } } if (fnf != null && fnf.Accept(this, name) == false) { continue; } if (name.Length > 0) { SmbFile f = new SmbFile(this, name, TypeFilesystem, e.GetAttributes (), e.CreateTime(), e.LastModified(), e.Length()); if (ff != null && ff.Accept(f) == false) { continue; } if (files) { list.Add(f); } else { list.Add(name); } } } if (resp.IsEndOfSearch || resp.NumEntries == 0) { break; } req.Reset(resp.ResumeKey, resp.LastName); resp.Reset(); Send(req, resp); } try { Send(new SmbComFindClose2(sid), Blank_resp()); } catch (SmbException se) { if (Log.Level >= 4) { Runtime.PrintStackTrace(se, Log); } } }