Jump to content

Access network share with alternate credentials


mojoxp

Recommended Posts

I've got a computer here that needs to go into a conference room and be logged in all the time. That's easy. The catch is that it needs to be able to access the central domain network share using a given users permissions from a desktop shortcut. That user needs to be able to quickly get access to their files and open them on the computer without logging directly into the machine. I've tried doing this with both RUNAS and CPAU, and they work but the problem is that they must copy over the user's profile in order to do so... which won't work for this situation. So what I need to figure out is how to have the user be able to click a link on the desktop and it will accept their credentials and then open the network share using those without having to load the profile over.

Any ideas?

Link to comment
Share on other sites


Sounds like you may be trying to overcomplicate things. I'm not 100% certain I understand what you want, but try the net use command to connect a drive letter...

net use * \\server\share /user:domain\user password /persistent:no

This will map a drive from one system to another using the credentials specified.

Link to comment
Share on other sites

Terminal Services session to a server that is a domain member?

If the files are held on a Windows Server, use IIS & WebDAV to access the files through a browser, and use integrated Windows authentication?

Link to comment
Share on other sites

Basically what we have is the single user setup on the laptop that's always logged in, and then we need the user to be able to access this network share using their credentials while still logged in as that user. I think I've got a solution worked out... I have a VBS script that executes and opens up an IE window to get thier user name and password. It then opens up the network share, and opens up an IE window that has a button for them to click to log them out of the network share. Its a bit complicated, but its the only solution I could come up with.

Here's the VBS Code:

' COMMENT: Gets a user's login name, then executes a RUNAS on the command prompt 
' that opens up Documents on Lexus with that user's credentials. For the
'
'
'
'
' **********************************************************************************
' Variable Declerations
' **********************************************************************************

On Error Resume Next
Dim WShell, strCommand
Set WshShell = CreateObject("Wscript.Shell")

' Open up Internet Exporer to get user input
Set objExplorer = WScript.CreateObject _
("InternetExplorer.Application", "IE_")

objExplorer.Navigate "file:///C:\Conference\Password.htm"
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Width = 400
objExplorer.Height = 350
objExplorer.Left = 300
objExplorer.Top = 200
objExplorer.Visible = 1

' Loop while waiting for IE to close
Do While (objExplorer.Document.Body.All.OKClicked.Value = "")
Wscript.Sleep 250
Loop


' Take in the input from IE
strUsername = objExplorer.Document.Body.All.UserName.Value
strPassword = objExplorer.Document.Body.All.UserPassword.Value
strButton = objExplorer.Document.Body.All.OKClicked.Value
objExplorer.Quit
Wscript.Sleep 250

'Add the domain to the user name
strUsername = strUsername & "@<FQDN>"

'If the user clicked cancel, then end the script, if not open the server share
If strButton = "Cancelled" Then
Wscript.Quit
Else
' Setup the path to the server using the user's input credentials
strCommand = "net use \\<server>\<share> " & strPassword & " /USER:" & strUsername
' Wscript.Echo strCommand
WshShell.Run strCommand,0,True

' Open up an explorer window to the network share
strCommand = "explorer.exe \\<server>\<share>\"
' Wscript.Echo strCommand
WshShell.Run strCommand,3,True

' Open up Internet Exporer to get the user to logout
Set objExplorer = WScript.CreateObject _
("InternetExplorer.Application", "IE_")
objExplorer.Navigate "file:///C:\Conference\Close.htm"
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Width = 400
objExplorer.Height = 350
objExplorer.Left = 300
objExplorer.Top = 200
objExplorer.Visible = 1

' Loop while waiting for IE to close
Do While (objExplorer.Document.Body.All.OKClicked.Value = "")
Wscript.Sleep 250
Loop

' Log the user out of Lexus
strCommand = "net use \\<server>\<share> /delete"
' Wscript.Echo strCommand
WshShell.Run strCommand,0,True
End If

Here's the first IE Window (Password.htm)

Sub RunScript
OKClicked.Value = "OK"
End Sub

Sub CancelScript
OKClicked.Value = "Cancelled"
End Sub

</SCRIPT>

<BODY>
<font size="2" face="Arial">
Username:    </font><font face="Arial">
<input type="InputBox" name="UserName" size="40"></font></p>
Password:    </font><font face="Arial">
<input type="password" name="UserPassword" size="40"></font></p>

<input type="hidden" name="OKClicked" size = "20">

<input id=runbutton class="button" type="button" value=" OK "
name="ok_button" onClick="RunScript">
   
<input id=runbutton class="button" type="button" value="Cancel"
name="cancel_button" onClick="CancelScript">

</BODY>

And here's the second (Close.htm)

<script LANGUAGE="VBScript">

Sub RunScript
OKClicked.Value = "OK"
End Sub

Sub CancelScript
OKClicked.Value = "Cancelled"
End Sub

</SCRIPT>

<BODY>
<font size="2" face="Arial">
Click the button below to log out of the network share     </font>
<input type="hidden" name="OKClicked" size = "20">

<input id=runbutton class="button" type="button" value=" OK "
name="ok_button" onClick="RunScript">

</BODY>

Edited by mojoxp
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...