Ejemplo n.º 1
0
        public Stream HtmlViewer(CTRL_LEVEL controlLevel)
        {
            // ensure connect rights and return the viewer
            DemandPermission(SessionRights.Connect);
            DisableCaching();
            var data = UserData.FromContext(session);

            WebOperationContext.Current.OutgoingResponse.ContentType = "text/html; charset=UTF-8";
            return(new MemoryStream
                   (
                       Encoding.UTF8.GetBytes
                       (
                           string.Format
                           (
                               "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n" +
                               "<html>\n" +
                               "  <head>\n" +
                               "    <title>{0}\\{1} @ {2}</title>\n" +
                               "    <meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\"/>\n" +
                               "  </head>\n" +
                               "  <body onload=\"try{{RDPViewer.DisconnectedText=decodeURIComponent('{5}');RDPViewer.Connect(decodeURIComponent('{3}'),decodeURIComponent('{4}'),'');}}catch(e){{alert(e.message);}}\" style=\"margin:0;padding:0;\">\n" +
                               "    <object id=\"RDPViewer\" classid=\"clsid:32be5ed2-5c86-480f-a914-0ff8885a1b3f\" width=\"100%\" height=\"100%\" style=\"border:0;margin:0;padding:0;\"></object>\n" +
                               "  </body>\n" +
                               "</html>",
                               Environment.UserDomainName,
                               Environment.UserName,
                               Environment.MachineName,
                               EscapeString(data.ConnectionString),
                               EscapeString(data.CreateAttendee(session, controlLevel)),
                               EscapeString(Properties.Settings.Default.DisconnectedText)
                           )
                       )
                   ));
        }
Ejemplo n.º 2
0
 public virtual void RequestControl(CTRL_LEVEL ctrlLevel)
 {
     if (this.ocx == null)
     {
         throw new AxHost.InvalidActiveXStateException("RequestControl", AxHost.ActiveXInvokeKind.MethodInvoke);
     }
     this.ocx.RequestControl(ctrlLevel);
 }
Ejemplo n.º 3
0
 public void OnControlLevelChangeRequest([In] object obj0, [In] CTRL_LEVEL obj1)
 {
     if (this.m_OnControlLevelChangeRequestDelegate == null)
     {
         return;
     }
     this.m_OnControlLevelChangeRequestDelegate(obj0, obj1);
 }
Ejemplo n.º 4
0
        public virtual void OnControlLevelChangeRequest(object pAttendee, CTRL_LEVEL requestedLevel)
        {
            _IRDPSessionEvents_OnControlLevelChangeRequestEvent _IRDPSessionEventsOnControlLevelChangeRequestEvent =
                new _IRDPSessionEvents_OnControlLevelChangeRequestEvent(pAttendee, requestedLevel);

            this.parent.RaiseOnOnControlLevelChangeRequest(
                this.parent,
                _IRDPSessionEventsOnControlLevelChangeRequestEvent);
        }
Ejemplo n.º 5
0
            public string CreateAttendee(RDPSession session, CTRL_LEVEL initialControlLevel = CTRL_LEVEL.CTRL_LEVEL_INVALID)
            {
                if (session == null)
                {
                    throw new ArgumentNullException("session");
                }

                // create a strong random hex string including the user name
                var userName = OperationContext.Current.ServiceSecurityContext.WindowsIdentity.Name;
                var buffer   = new byte[64];
                var builder  = new StringBuilder(userName.Length + buffer.Length * 2 + 2);

TryAgain:
                rng.GetBytes(buffer);
                builder.Length = 0;
                if (userName.IndexOf('\\') == -1)
                {
                    builder.Append('\\');
                }
                builder.Append(userName);
                builder.Append('\\');
                for (int i = 0; i < buffer.Length; i++)
                {
                    builder.Append(buffer[i].ToString("X2", CultureInfo.InvariantCulture));
                }
                var attendeeName = builder.ToString();

                // make sure it doesn't exist
                lock (issuedAttendeeNames)
                {
                    if (issuedAttendeeNames.Contains(attendeeName))
                    {
                        goto TryAgain;
                    }
                    issuedAttendeeNames.Add(attendeeName);
                }

                // create a new pending connection and return the attendee name
                lock (connectionLock)
                {
                    pendingConnections.Add(attendeeName, new PendingConnection()
                    {
                        TimeoutTimer        = new Timer(ConnectionTimeout, attendeeName, Properties.Settings.Default.ConnectionTimeout, TimeSpan.Zero),
                        InitialControlLevel = initialControlLevel,
                    });
                }
                return(attendeeName);
            }
Ejemplo n.º 6
0
        void OnControlLevelChangeRequest(object pAttendee, CTRL_LEVEL RequestedLevel)
        {
            var attendee = (IRDPSRAPIAttendee)pAttendee;

            try
            {
                // get the user data and check the known control levels
                var data = UserData.FromAttendee(attendee);
                if (data != null)
                {
                    switch (RequestedLevel)
                    {
                    case CTRL_LEVEL.CTRL_LEVEL_NONE:
                        if ((data.EffectivePermissions & SessionRights.Connect) == 0)
                        {
                            return;
                        }
                        break;

                    case CTRL_LEVEL.CTRL_LEVEL_VIEW:
                        if ((data.EffectivePermissions & SessionRights.View) == 0)
                        {
                            return;
                        }
                        break;

                    case CTRL_LEVEL.CTRL_LEVEL_INTERACTIVE:
                        if ((data.EffectivePermissions & SessionRights.Interact) == 0)
                        {
                            return;
                        }
                        break;

                    default:
                        return;
                    }

                    // set the requested control level
                    attendee.ControlLevel = RequestedLevel;
                }
            }
            finally { Marshal.ReleaseComObject(attendee); }
        }
Ejemplo n.º 7
0
        void OnControlLevelChangeRequest(object pObjAttendee, CTRL_LEVEL RequestedLevel)
        {
            IRDPSRAPIAttendee pAttendee = pObjAttendee as IRDPSRAPIAttendee;

            //pAttendee.ControlLevel = RequestedLevel;
            //textBox1.AppendText(RequestedLevel.ToString() + Environment.NewLine);
            //textBox1.AppendText(Environment.NewLine + RequestedLevel.ToString());
            //BinaryWriter
            //System.Net.Sockets.SendPacketsElement test = new S;
            //System.Net.Sockets.NetworkStream Test;
            //IRDPSRAPITransportStream.WriteBuffer.ToString();
            //IRDPSRAPITransportStream.WriteBuffer(RDPCOMAPILib.RDPTransportStreamBuffer)
            //if (_checkSwitch == true)
            if (checkBox1.Checked == true)
            {
                pAttendee.ControlLevel = RequestedLevel;
                textBox1.AppendText(Environment.NewLine + RequestedLevel.ToString());
            }
            else
            {
                pAttendee.ControlLevel = CTRL_LEVEL.CTRL_LEVEL_VIEW;
                textBox1.AppendText(Environment.NewLine + RequestedLevel.ToString());
            }
        }
Ejemplo n.º 8
0
 public virtual extern void RequestControl([ComAliasName("RDPCOMAPILib.CTRL_LEVEL"), In] CTRL_LEVEL CtrlLevel);
Ejemplo n.º 9
0
 void rdpSession_OnControlLevelChangeRequest(object pAttendee, CTRL_LEVEL RequestedLevel)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 10
0
        private void RdpSessionOnOnControlLevelChangeRequest(object pObjAttendee, CTRL_LEVEL RequestedLevel)
        {
            IRDPSRAPIAttendee pAttendee = pObjAttendee as IRDPSRAPIAttendee;

            Console.WriteLine(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + ":" + pAttendee.Id + "," + pAttendee.RemoteName + ":请求更好权限。");
        }
Ejemplo n.º 11
0
        private void ControlLevelChange(Object client, CTRL_LEVEL RequestedLevel)
        {
            IRDPSRAPIAttendee Client = (IRDPSRAPIAttendee)client;

            Client.ControlLevel = RequestedLevel;
        }
Ejemplo n.º 12
0
 private void RdpSessionOnOnControlLevelChangeRequest(object pAttendee, CTRL_LEVEL requestedLevel)
 {
     //throw new NotImplementedException();
     // Do nothing...
 }
Ejemplo n.º 13
0
        /**
         * (see StartRDPSession) this whole method may not be needed
         */
        private void OnGuruChangeControlLevel(object attendee, CTRL_LEVEL level)
        {
            IRDPSRAPIAttendee guru = attendee as IRDPSRAPIAttendee;

            guru.ControlLevel = level;
        }
Ejemplo n.º 14
0
 //_IRDPSessionEvents.OnControlLevelChangeResponse(object, RDPCOMAPILib.CTRL_LEVEL, int)
 //_IRDPSessionEvents_OnSharedDesktopSettingsChangedEventHandler(int width, int height, int colordepth)
 void OnControlLevelChangeResponse(object pAttendee, CTRL_LEVEL RequestedLevel, int ReasonCode)
 {
     LogTextBox.AppendText("Level Changed " + ReasonCode + Environment.NewLine);
     //   _IRDPSessionEvents_Event_OnControlLevelChangeResponse
 }
 public _IRDPSessionEvents_OnControlLevelChangeRequestEvent(object pAttendee, CTRL_LEVEL requestedLevel)
 {
     this.pAttendee      = pAttendee;
     this.requestedLevel = requestedLevel;
 }
        void OnControlLevelChangeRequest(object pObjAttendee, CTRL_LEVEL RequestedLevel)
        {
            IRDPSRAPIAttendee pAttendee = pObjAttendee as IRDPSRAPIAttendee;

            pAttendee.ControlLevel = RequestedLevel;
        }
Ejemplo n.º 17
0
        public void ChangeControl(object Client, CTRL_LEVEL level)
        {
            IRDPSRAPIAttendee attendee = (IRDPSRAPIAttendee)Client;

            attendee.ControlLevel = level;
        }