Jump to content

Mapping drives from non domain pcs via scripts


Recommended Posts

Posted

Does anybody have a script (or know an app that will do it) that will prompt for a username and password then query Active Directory to find the users homedrive and then map the drive on the PC?

 

As I want to be able to remove some of our class sets from the domain as 90% of the time they just use it for web browsing which will be alot quicker from power on to being usable for students.

Posted

Ok maybe someone can pick up from this and figure out how to tie it in with AD...

 

I use bat files to map drive for people that don't have/want domain attached machines.

 

net use X: \\server\folder\ /user:domain\userid password

 

Change where it says "server" to the name of the server, "folder" to the location and you can keep digging as deep as needed so as to tie into people's storage drives.

 

Then replace "userid" with the login name and "password" with their password.

 

Yes it's simple and boring to make loads of these, but it has served well for me :smash:

Posted
Ok maybe someone can pick up from this and figure out how to tie it in with AD...

 

I use bat files to map drive for people that don't have/want domain attached machines.

 

net use X: \\server\folder\ /user:domain\userid password

 

Change where it says "server" to the name of the server, "folder" to the location and you can keep digging as deep as needed so as to tie into people's storage drives.

 

Then replace "userid" with the login name and "password" with their password.

 

Yes it's simple and boring to make loads of these, but it has served well for me :smash:

 

 

Yeah I have that part as have been given a autoit script from somebody at another school but not all my users are on the same file server which is where I need the AD query for the homepath.

 

So far i have

 

Local $Username, $Password, $Result, $Flag

$Flag = 0

RunWait("cmd /c net use w: /DELETE")
RunWait("cmd /c net use p: /DELETE")

Do
if $Flag = 1 Then
	MsgBox(0,"Error","Your username or password were incorrect. Please try again")
EndIf

$Flag = 1
$Username = InputBox("Logon to Network Drives", "Please enter your username:","","",150,80)

if $Username = "" then
	Exit
endif

$Password = InputBox ("Logon to Network Drives", "Please enter your password:","","!",150,80)

if $Password = "" then
	Exit
endif

$Result = RunWait("cmd /c net use N: \\server\share " & $Password & " /USER:" & $Username & " /PERSISTENT:NO")
$Result = RunWait("cmd /c net use R: \\server\sharedarea " & $Password & " /USER:" & $Username & " /PERSISTENT:NO")

Until $Result = 0 AND NOT @error
Exit

 

I just need to find something i can use for a query to ad to output to say $homedrive

 

then add the variable to the $result instead of \\server\share

 

Toby

Posted
I just need to find something i can use for a query to ad to output to say $homedrive

 

then add the variable to the $result instead of \\server\share

 

It's been a while since I've used AutoIt but what about this for a slightly different way of looking at the problem.

 

Instead of using RunWait to launch an external command to map the drive, why not use AutoIt's DriveMapAdd command instead? The advantage here is that if it fails it will return an @error code showing the reason. You could then write an IF loop to try out the different places where the homedrive could be stored until it finds one that exists.

 

Secondly I believe that one of the @error conditions also flags an incorrect password allowing you to provide a friendly prompt in the case of typos.

 

Not the cleanest way I know but it might just work?

Posted

Yes drive mapadd until it finds one was a suggestion somebody else made - although having each year group on a different share it could take forever to find one. As we would have

 

\\FS1\INTAKE10$\USERNAME

\\FS2\intake10$\username

 

And on for each year group 7-13 across 6 file servers the users at the bottom might be there a week!

Posted
Just wondering if anybody else has any thoughts to this as i'm stumped as can't find anything i can use - although I think it must be do able.
Posted
I could probably whip up something in VBScript if you want. The only problem I foresee is the password box; does your current script mask the passwords with dots or asterisks?
Posted
I could probably whip up something in VBScript if you want. The only problem I foresee is the password box; does your current script mask the passwords with dots or asterisks?

 

If you could that would be great - never really played with vbs.

 

Currently it uses this line

$Password = InputBox ("Logon to Network Drives", "Please enter your password:","","!",150,80)

 

 

and hides text input with !

 

Cheers

Posted
If not just a vbscript which can query ad and get me the Homedirectory path for a user. I might be able to then play with autoit to get the username/password into it.
Posted

Just an idea - are you usernames mapped to user folder names in any sort of logical way

 

e.h user jsmith11 - user folder is \\server\pupils\2011leaver\jsmith ??

 

Then you wouldn't need to query AD.

 

regards

 

Simon

PS I would imagine that a non-domain machine wouldn't be able to access AD info for security reasons BTW

Posted
Just an idea - are you usernames mapped to user folder names in any sort of logical way

 

e.h user jsmith11 - user folder is \\server\pupils\2011leaver\jsmith ??

 

Then you wouldn't need to query AD.

 

regards

 

Simon

PS I would imagine that a non-domain machine wouldn't be able to access AD info for security reasons BTW

 

Not querying AD would be much, much easier, although it is possible to query AD from a non-domain machine. The problem I came across when doing research on it last night is that it requires a set of credentials for an account that is able to query AD in the script, which might cause a potential security issue.

Posted
Not querying AD would be much, much easier, although it is possible to query AD from a non-domain machine. The problem I came across when doing research on it last night is that it requires a set of credentials for an account that is able to query AD in the script, which might cause a potential security issue.

 

hmm - can it not use the credentials which will be inputed? As each user has the rights to view their own personal information as they need to be able to see their home directory/profile paths etc

Posted
hmm - can it not use the credentials which will be inputed? As each user has the rights to view their own personal information as they need to be able to see their home directory/profile paths etc

 

I don't know if those credentials will be able to query AD, but I can always try it. :)

Posted

A bit of googling has all sorts of requests to query AD from non-domain but the answers don't inspire confidence that what you want can be done :(

 

Liek I said, if your username to userfolder mapping follows any type of simple logic then it would be easy to do the mapping.

Or maybe if your folder structure is something like

 

\\server\userfiolders\year11\jsmith

 

you could ask for year group in logon and map H: to \\server\usersfolders\year11 and then let them select their folder from there.

 

Maybe another way is to do an username/foldername text file export from AD that is parsed by the non-domain logon script.

 

(If one of big boys/girls could knock up such a script - it'd be very usefull - I can't spull AD myself :) )

 

As long as usernames/passwords wern't changing very much this wouldn't be too hard to manage?

 

This could turn into quite a useful project for "dirty" networks :)

 

regards

Posted

My year groups are spilt across file servers - as the timetable works (for senior years) so that all 300 login at once! which slows logins down. I have reduced login time by around a minute by spilting year groups across servers. So a third of the year point to one server - a third to another and a third to another.

 

But actually a script which pulls out to a text file would work as it can look for the username and then map the drive - with only users with permissions to the home dirs only being allowed to map the dirs.

Posted
But actually a script which pulls out to a text file would work as it can look for the username and then map the drive - with only users with permissions to the home dirs only being allowed to map the dirs.

 

That would probably be easier. I do apologise for not having got back to this sooner, we've had a few issues over here so I haven't had chance to work on it. What format would the data in the text file be laid out in?

Posted
Okie dokie. If we're going to go down that route, then I could probably just modify the script you have now, meaning passwords would be masked. Let us know when you have the extra information. :)
Posted

Ok - I have a script which will pull users out into a csv with the following headings.

 

DN,homeDirectory,sAMAccountName

 

To run the script to check

csvde -f exportusershomedir.csv -r objectcategory=user -l "SAMaccountname, h
omedirectory"

  • Thanks 1
Posted
Just remebered i need to write something to process the file afterwards as the output of homedirectory has double the amount of backslashes it should. not sure why. so each one is \\\\server\\share\\username
Guest TheLibrarian
Posted (edited)

Use DSQuery to get their home path, you can get the user name in the script and DSQuery will request their password if you supply the correct parameters thus solving the password in plain text problem.

 

The down side is they will likely have to enter their password twice, once for the DSQuery and once to map the drive.

 

There is an off the wall suggestion: schedule a task on the PC's to grab a list of home directories and then filter that against the user name the user enters.

 

Edit: I guess it's not that off the wall, it looks like someone suggested / thought of that already - I didn't read the entire thread.

Edited by TheLibrarian
Didn't read the entire thread...
Guest TheLibrarian
Posted
Just remebered i need to write something to process the file afterwards as the output of homedirectory has double the amount of backslashes it should. not sure why. so each one is \\\\server\\share\\username

 

I'm guessing \ is an escape character.

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



×
×
  • Create New...