Exemple #1
0
        /// <summary>
        ///   Changes password on the server
        /// </summary>
        /// <param name = "user">user name</param>
        /// <param name = "oldpwd">old password</param>
        /// <param name = "newpwd">new password</param>
        public void ChangePassword(string user, string oldpwd, string newpwd)
        {
            lock (this)
            {
                if (Debug.DebugOn)
                {
                    Debug.WriteLine(Debug.Info, "SamOEMChangePassword");
                }

                var param = new MarshalBuffer(100);

                int pos = 0;
                pos += param.SetShortAt(pos, SamOEMChangePassword);
                // parameter descriptor string
                pos += param.SetZtAsciiStringAt(pos, "zsT");

                // the data descriptor string for the (returned) data which = null string
                pos += param.SetZtAsciiStringAt(pos, "B516B16");

                // user
                pos += param.SetZtAsciiStringAt(pos, user);

                // data size
                pos += param.SetShortAt(pos, 532);

                param.Size = pos;

                byte[] data = CifsLogin.GetChangePasswordData(oldpwd, newpwd);


                SendTransaction(null, "\\PIPE\\LANMAN", param, data, data.Length);

                var rdata = new MarshalBuffer(100);

                receiveTransaction(param, rdata);

                pos = 0;

                int error = param.GetShortAt(pos);

                // ignore more data
                if (error != 0 && error != 234)
                {
                    throw CifsIoException.getLMException(error);
                }
            } // lock
        }
Exemple #2
0
        /// <summary>
        ///   Clone this object
        /// </summary>
        public object Clone()
        {
            var newlogin = new CifsLogin();

            lock (this)
            {
                if (Account != null)
                {
                    newlogin.Account = (string)Account.Clone();
                }
                if (Password != null)
                {
                    newlogin.Password = (string)Password.Clone();
                }
            }

            return(newlogin);
        }
Exemple #3
0
        private static void DoRemoteAdmin()
        {
            var login = new CifsLogin("guest", null);
            ICifsRemoteAdmin ra = null;
            try
            {
                // in this example, "test" is the session name, "athena" the hostname.
                // you can enter any validly resolving entry for the hostname (IP, computername, etc)
                ra = CifsSessionManager.ConnectRemoteAdmin("test", "athena", login);

                ShowServer(ra);

                Console.WriteLine("\nShare's");
                DoShares(ra);

                Console.WriteLine("\nWorkstation Info");
                DoWInfo(ra);

                Console.WriteLine("\nServer Info");
                DoSInfo(ra);


                Console.Read(); // pause

                ICifsSession s = ra;

                s.Disconnect();
            }
            catch (Exception) // ignore all
            {
                if (ra != null)
                {
                    ICifsSession s = ra;
                    s.Disconnect();
                }
            }
        }
Exemple #4
0
 internal Share(string name, int type, CifsLogin login)
 {
     SetName(name);
     ShareType = type;
     Login = login;
 }
Exemple #5
0
 internal Share(string name, int type)
 {
     SetName(name);
     ShareType = type;
     Login = new CifsLogin();
 }
Exemple #6
0
 internal Share(CifsLogin login)
 {
     ShareType = DISK;
     Login = login;
 }
Exemple #7
0
        /// <summary>
        ///   Connect to Remote Admin Protocol
        /// </summary>
        /// <param name = "sessionname">local alias name for this connection</param>
        /// <param name = "host">host name</param>
        /// <param name = "login">authentication data</param>
        public static ICifsRemoteAdmin ConnectRemoteAdmin(string sessionname, string host, CifsLogin login)
        {
            // check if the admname connection is already open
            ICifsSession session = LookupSession(sessionname);

            if (session != null)
            {
                throw new CifsIoException("SS1", sessionname);
            }

            if (login == null)
            {
                login = fDefaultLogin;
            }

            var share = new Share(login);

            share.SetInfo(Share.IPC, host, "IPC$");

            var        nbt = new NbtSession();
            SmbMessage smb = CifsSession.AllocateSmbMessage();

            int             protocol;
            CifsRemoteAdmin admin = null;

            try
            {
                protocol = CifsSession.Negotiate(nbt, share.HostName, smb);
                admin    = new CifsRemoteAdmin(sessionname, protocol, share, nbt, smb);
                admin.Connect();
            }
            catch (IOException e)
            {
                //nbt.doHangup();
                if (admin != null)
                {
                    admin.Dispose();
                }
                else
                {
                    nbt.DoHangup();
                }


                throw;
            }

            return(admin);
        }
Exemple #8
0
        /// <summary>
        ///   Clone this object
        /// </summary>
        public object Clone()
        {
            var newlogin = new CifsLogin();

            lock (this)
            {
                if (Account != null)
                    newlogin.Account = (string) Account.Clone();
                if (Password != null)
                    newlogin.Password = (string) Password.Clone();
            }

            return newlogin;
        }
Exemple #9
0
 internal Share(string name, int type, CifsLogin login)
 {
     SetName(name);
     ShareType = type;
     Login     = login;
 }
Exemple #10
0
 internal Share(string name, int type)
 {
     SetName(name);
     ShareType = type;
     Login     = new CifsLogin();
 }
Exemple #11
0
 internal Share(CifsLogin login)
 {
     ShareType = DISK;
     Login     = login;
 }