internal SmbTree GetSmbTree(string share, string service) { lock (this) { SmbTree t; if (share == null) { share = "IPC$"; } /*for (IEnumeration e = trees.GetEnumerator(); e.MoveNext(); ) * { * t = (SmbTree)e.Current; * if (t.Matches(share, service)) * { * return t; * } * }*/ foreach (var e in Trees) { t = (SmbTree)e; if (t.Matches(share, service)) { return(t); } } t = new SmbTree(this, share, service); Trees.Add(t); return(t); } }
public override bool Equals(object obj) { if (obj is SmbTree) { SmbTree tree = (SmbTree)obj; return(Matches(tree.Share, tree.Service)); } return(false); }
/// <exception cref="WinrtCifs.Smb.SmbException"></exception> internal virtual DfsReferral GetDfsReferrals(NtlmPasswordAuthentication auth, string path, int rn) { SmbTree ipc = GetSmbSession(auth).GetSmbTree("IPC$", null); Trans2GetDfsReferralResponse resp = new Trans2GetDfsReferralResponse(); ipc.Send(new Trans2GetDfsReferral(path), resp); if (resp.NumReferrals == 0) { return(null); } if (rn == 0 || resp.NumReferrals < rn) { rn = resp.NumReferrals; } DfsReferral dr = new DfsReferral(); string[] arr = new string[4]; long expiration = Runtime.CurrentTimeMillis() + Dfs.Ttl * 1000; int di = 0; for (; ;) { dr.ResolveHashes = auth.HashesExternal; dr.Ttl = resp.Referrals[di].Ttl; dr.Expiration = expiration; if (path.Equals(string.Empty)) { dr.Server = Runtime.Substring(resp.Referrals[di].Path, 1).ToLower(); } else { DfsPathSplit(resp.Referrals[di].Node, arr); dr.Server = arr[1]; dr.Share = arr[2]; dr.Path = arr[3]; } dr.PathConsumed = resp.PathConsumed; di++; if (di == rn) { break; } dr.Append(new DfsReferral()); dr = dr.Next; } return(dr.Next); }
/// <exception cref="WinrtCifs.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); } }