Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account


Photo

Access network share with alternate credentials

- - - - -

  • Please log in to reply
4 replies to this topic

#1
mojoxp

mojoxp

    Newbie

  • Member
  • 16 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?


How to remove advertisement from MSFN

#2
Noise

Noise

    Windows Guru

  • Member
  • PipPipPip
  • 425 posts
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.

#3
Mr Snrub

Mr Snrub

    Former MSFT

  • Super Moderator
  • 775 posts
  • OS:Windows 8 x64
  • Country: Country Flag
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?

My TechNet Blog
I have CDO. It's like OCD except the letters are in alphabetical order, as they should be.


#4
nitroshift

nitroshift

    Beware of programmers with screwdrivers!

  • Super Moderator
  • 2,904 posts
  • OS:Windows 8.1 x64
  • Country: Country Flag
didn't quite undersand your problem, but since you already shared the resource, isn't it easier to just set the permissions for that user and map the resource?

Please read the rules, folks!


#5
mojoxp

mojoxp

    Newbie

  • Member
  • 16 posts
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:&nbsp;&nbsp;&nbsp; </font><font face="Arial">
<input type="InputBox" name="UserName" size="40"></font></p>
Password:&nbsp;&nbsp;&nbsp; </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">
&nbsp;&nbsp;&nbsp;
<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 &nbsp;&nbsp;&nbsp; </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, 31 May 2006 - 02:16 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users



How to remove advertisement from MSFN