Run the Jupyterlab server as runas /netonly?

How can I run my Jupyterlab server as runas /netonly?

Or the equivalent in Powershell? On Windows?

So I created a different Windows account, and I installed Anaconda there.

When I log back into my regular account, I open a powershell window as another user run the Anaconda PS Prompt startup script and attempt to run Jupyterlab from there.

It starts the webserver for Jupyterlab, but when I visit it in my browser it just says that Jupyterlab is running; it doesn’t actually allow me to login; I’ve also tried pasting the token, but no dice.

So nobody knows anything about this? I have trouble believing that.

I imagine most people on Windows probably run JupyterLab as themselves.

More advanced JupyterLab setups tend to be on Linux, e.g. using JupyterHub to serve multiple users, or something else.

Well if they do, then they are doing it wrong. Because you shouldn’t use your default or admin windows account to login to an SQL server; how do you think data breaches happen?

Someone clicks on a link in an email that kicks off a script with your user account to SQL Server and dumps the data and sends it somewhere it shouldn’t go.

If you’re going to use Jupyter to access a database it should be using an domain account or a database local account to access it.

If you’re doing it any other way, you’re putting the data in the database at risk; especially if you’re running Windows.

I think non-administrators like data science people don’t realize that; their IT Departments should make them realize that. but maybe they don’t.

Your original post didn’t mention running JupyterLab on SQL server, nor did it mention why you were logged on as admin, so I just assumed you were trying to use runas for curiosity!

If it’s a production SQLserver and you’re concerned about security I’d have thought you wouldn’t want to run JupyterLab on it, instead wouldn’t you run it on a separate system and connect to SQLserver over an authenticated connection?

It is not running on SQL Server; it’s connecting remotely to SQL Server; sorry if that wasn’t clear.

This is how to do this:

  1. Python needs to be installed for all users in computer. !Very important
  2. Install Visual C++ Build tools
    Microsoft C++ Build Tools - Visual Studio
  3. Create a directory for the virtualenv accesible by all users in the computer, for example:
    mkdir C:\virtualenv
  4. Make a copy of the Command Prompt and paste in the virtualenv directory.
    From: C:\Users\YOURUSERNAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\System Tools\Command Prompt
    To: C:\virtualenv\Command Prompt
  5. Run Command Prompt as different user (press shift + right click) and login with YOURDOMAIN.
    password: your password
  6. cd C:\virtualenv
  7. Create the virtualenv:
    python -m venv .
  8. Connect to the virtualenv.
  9. Install dependencies
    pip install --upgrade jupyter pyodbc sqlalchemy pandas pip
  10. Create a Jupyter configuration file for the user.
    jupyter notebook --generate-config
  11. Close the Command Prompt.
  12. Right click on the Command Prompt shortcut, then select Properties.
  13. Clear and leave empty the values from Start in and replace the Target values with:
    Target: %windir%\system32\runas.exe /user:YOURUSERNAME@DOMAIN /netonly “CMD /k "cd C:\virtualenv && Scripts\activate && jupyter notebook”"
    **Optional: You may add /savecred (after/user) and it will remember the password. I do not recommend doing this.
  14. Double click the command prompt to run Jupyter.
  15. Create a notebook to connect to your SQL database and download a table into a Pandas dataframe:

import pyodbc
import sqlalchemy as db
import pandas as pd

import os
windomain = os.environ[‘userdomain’]

if windomain == “YOURDOMAIN”:
server = ‘YOURSERVER’
database = ‘YOUDATABASE’
driver = “{SQL Server}”
# ** No need to type user or password.
connect = “DRIVER=”+driver+“;SERVER=”+server+“;DATABASE=”+database+“;Trusted_Connection=yes”
engine = db.create_engine(“mssql+pyodbc:///?odbc_connect={}”.format(connect))
print(“Open as different user.”)

df = pd.read_sql(