logo

The ConnectWise Control forum has moved to ConnectWise University! This forum has been locked and is in read-only mode. Click here for instructions on how to access the new forum.

Welcome Guest! You can not login or register.

Notification

Icon
Error

Options
Go to last post Go to first unread
bigdessert  
#1 Posted : Thursday, October 21, 2010 11:16:48 PM(UTC)
bigdessert


Rank: Advanced Member

Medals: ScreenConnect Advisor: Focus Group MemberLevel 3: Shirt off your back! Received 25 Thanks!

Joined: 9/13/2010(UTC)
Posts: 708
Location: Minnesota

Thanks: 1 times
Was thanked: 44 time(s) in 32 post(s)
Let's say I have a 5 connection license.

Is there any way to limit user1 to 2 sessions and user2 to 3 sessions?

Jake  
#2 Posted : Friday, October 22, 2010 7:11:01 PM(UTC)
Jake


Rank: Administration

Medals: Level 4: Wise Old Owl! Received 100 Thanks!

Joined: 4/9/2010(UTC)
Posts: 2,061

Thanks: 1 times
Was thanked: 393 time(s) in 188 post(s)
You could add a line of custom code to Host.aspx.

something like:

if (sessionManager.GetSessions().Count(s => s.Host == this.User.Identity.Name) > 2)
throw new InvalidOperationException("You can only create 2 sessions.");

It should be in the CreateSession method. I can look at in on Monday to tell you an exact line if you need more help.
ScreenConnect Team
tom  
#3 Posted : Sunday, October 24, 2010 10:53:09 PM(UTC)
Guest


Rank: Advanced Member

Medals: Level 1: Random Act of Kindness! Received One Thanks!

Joined: 4/9/2010(UTC)
Posts: 331

Was thanked: 2 time(s) in 2 post(s)
I was able to get it to work by making "sessionManager" with a capitol "S" and inputed it just below the CreateSession() in the host.aspx.cs file.

It works but how do I limit it per user. So how can I say User "A" can have 3 connections but User "B" can only have 1.

Thanks
Tom

Edited by user Sunday, October 24, 2010 11:05:05 PM(UTC)  | Reason: Not specified

bigdessert  
#4 Posted : Monday, October 25, 2010 9:40:43 AM(UTC)
bigdessert


Rank: Advanced Member

Medals: ScreenConnect Advisor: Focus Group MemberLevel 3: Shirt off your back! Received 25 Thanks!

Joined: 9/13/2010(UTC)
Posts: 708
Location: Minnesota

Thanks: 1 times
Was thanked: 44 time(s) in 32 post(s)
tom wrote:
I was able to get it to work by making "sessionManager" with a capitol "S" and inputed it just below the CreateSession() in the host.aspx.cs file.

It works but how do I limit it per user. So how can I say User "A" can have 3 connections but User "B" can only have 1.

Thanks
Tom


Here is what I changed my createsession function to.

Code:
		private void CreateSession()
		{
			InvitationType invitationType;
			string tag;
			
			if (Page.User.Identity.Name == "UserA")
				{
				if (SessionManager.GetSessions().Count(s => s.Host == this.User.Identity.Name) >= 0)
				{
				throw new InvalidOperationException("UserA you can only create 0 sessions.");
				}
			}
			else
			{
				if (this.listedButton.Visible && this.listedButton.Checked)
				{
					invitationType = InvitationType.Listed;
					tag = this.noteBox.GetTrimmedOrNullText();
				}
				else if (this.emailButton.Visible && this.emailButton.Checked)
				{
					invitationType = InvitationType.Email;
					tag = this.emailBox.GetTrimmedOrNullText();
				}
				else if (this.codeButton.Visible && this.codeButton.Checked)
				{
					invitationType = InvitationType.Code;
					tag = this.codeBox.GetTrimmedOrNullText();
				}
				else
				{
					throw new InvalidOperationException("Invalid invitation.");
				}

				var session = this.SessionManager.CreateSession(invitationType, tag, this.User.Identity.Name);

				if (invitationType == InvitationType.Email)
				{
					try
					{
						var addressableUri = ServerExtensions.GetWebServerUri(ConfigurationManager.AppSettings, this.Request.Url, true);
						var pageUrl = new Uri(addressableUri, ServerConstants.GuestPageName).ToString();
						var sessionGuestUrl = WebExtensions.GetUrl(pageUrl, ServerConstants.SessionIDParameterName, session.SessionID);

						var mailMessage = new MailMessage();
						mailMessage.To.Add(session.Tag);
						mailMessage.Subject = string.Format(WebResources.CreateSessionsPanel_EmailSubject, session.Host, sessionGuestUrl);
						mailMessage.Body = string.Format(WebResources.CreateSessionsPanel_EmailBody, session.Host, sessionGuestUrl);

						var client = new SmtpClient();
						client.Send(mailMessage);
					}
					catch
					{
						this.SessionManager.AddSessionEvent(session.SessionID, ProcessType.Host, SessionEventType.EndedSession, null);
						throw;
					}
				}
			}
		}


This will first check if the user is userA, then limit the connection. If it is userB it will not check. you would just need another else if statement to check if it is userB and userC so on.
bigdessert  
#5 Posted : Monday, October 25, 2010 9:58:30 AM(UTC)
bigdessert


Rank: Advanced Member

Medals: ScreenConnect Advisor: Focus Group MemberLevel 3: Shirt off your back! Received 25 Thanks!

Joined: 9/13/2010(UTC)
Posts: 708
Location: Minnesota

Thanks: 1 times
Was thanked: 44 time(s) in 32 post(s)
made a little more modification. this requires less code mangling. This gives userA 1 session, userB 2 sessions and all other users 10 sessions. I have no clue how to code asp, I am php coder, but maybe Jake can chime in for a way that we could just have a line in the User.xml file and just read a line for <AllowedSessionsCount> or something of that matter. I would assume it would be very easy for them to add this in as a box when creating or editing a user.


Code:
		private void CreateSession()
		{
			InvitationType invitationType;
			string tag;
			int sessions;
			if(Page.User.Identity.Name == "UserA")
			{
			sessions = 1;
			}
			else if(Page.User.Identity.Name == "UserB")
			{
			sessions = 2;
			}
                        else
			{
			sessions = 10;
			}
			if (SessionManager.GetSessions().Count(s => s.Host == this.User.Identity.Name) >= sessions)
			{
			throw new InvalidOperationException("You can only create " + sessions + " sessions.");
			}
			else if (this.listedButton.Visible && this.listedButton.Checked)
			{
				invitationType = InvitationType.Listed;
				tag = this.noteBox.GetTrimmedOrNullText();
			}
			else if (this.emailButton.Visible && this.emailButton.Checked)
			{
				invitationType = InvitationType.Email;
				tag = this.emailBox.GetTrimmedOrNullText();
			}
			else if (this.codeButton.Visible && this.codeButton.Checked)
			{
				invitationType = InvitationType.Code;
				tag = this.codeBox.GetTrimmedOrNullText();
			}
			else
			{
				throw new InvalidOperationException("Invalid invitation.");
			}

			var session = this.SessionManager.CreateSession(invitationType, tag, this.User.Identity.Name);

			if (invitationType == InvitationType.Email)
			{
				try
				{
					var addressableUri = ServerExtensions.GetWebServerUri(ConfigurationManager.AppSettings, this.Request.Url, true);
					var pageUrl = new Uri(addressableUri, ServerConstants.GuestPageName).ToString();
					var sessionGuestUrl = WebExtensions.GetUrl(pageUrl, ServerConstants.SessionIDParameterName, session.SessionID);

					var mailMessage = new MailMessage();
					mailMessage.To.Add(session.Tag);
					mailMessage.Subject = string.Format(WebResources.CreateSessionsPanel_EmailSubject, session.Host, sessionGuestUrl);
					mailMessage.Body = string.Format(WebResources.CreateSessionsPanel_EmailBody, session.Host, sessionGuestUrl);

					var client = new SmtpClient();
					client.Send(mailMessage);
				}
				catch
				{
					this.SessionManager.AddSessionEvent(session.SessionID, ProcessType.Host, SessionEventType.EndedSession, null);
					throw;
				}
			}
		}
Jake  
#6 Posted : Thursday, October 28, 2010 9:57:36 AM(UTC)
Jake


Rank: Administration

Medals: Level 4: Wise Old Owl! Received 100 Thanks!

Joined: 4/9/2010(UTC)
Posts: 2,061

Thanks: 1 times
Was thanked: 393 time(s) in 188 post(s)
We'll enter it as an enhancement

I certainly agree it would help to integrate that data into our user data file rather than being in the code. You can extend our XmlMembershipProvider class, but the class wasn't designed with this kind of extensibility in mind, so that could be challenging. Maintaining a separate data file yourself would be fairly straightforward. Integrating it into the user creation UI could get tricky. I suppose your best choice depends on how many users you have and how often you'll need to make changes.
ScreenConnect Team
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.