/// <exception cref="SharpCifs.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="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); } }