glennda Posted January 21, 2011 Posted January 21, 2011 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.
MaceZ4 Posted January 21, 2011 Posted January 21, 2011 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
glennda Posted January 21, 2011 Author Posted January 21, 2011 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 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
michaelf Posted January 22, 2011 Posted January 22, 2011 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?
glennda Posted January 22, 2011 Author Posted January 22, 2011 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!
glennda Posted January 22, 2011 Author Posted January 22, 2011 having just seem this thread some of the software mentioned there might also work - i'll look into it further next week. but my prefered method would be a script of somesort
glennda Posted January 24, 2011 Author Posted January 24, 2011 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.
JHeaton Posted January 24, 2011 Posted January 24, 2011 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?
glennda Posted January 24, 2011 Author Posted January 24, 2011 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
JHeaton Posted January 24, 2011 Posted January 24, 2011 Okay, I'm not 100% sure that VBScript can do that, but I should be able to find a solution. I'll get back to you in a day or so.
glennda Posted January 24, 2011 Author Posted January 24, 2011 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.
SimpleSi Posted January 24, 2011 Posted January 24, 2011 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
JHeaton Posted January 25, 2011 Posted January 25, 2011 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.
glennda Posted January 25, 2011 Author Posted January 25, 2011 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
JHeaton Posted January 25, 2011 Posted January 25, 2011 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.
SimpleSi Posted January 25, 2011 Posted January 25, 2011 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
glennda Posted January 25, 2011 Author Posted January 25, 2011 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.
JHeaton Posted January 26, 2011 Posted January 26, 2011 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?
glennda Posted January 26, 2011 Author Posted January 26, 2011 hmm not sure. I will have a play and get back to you.
JHeaton Posted January 26, 2011 Posted January 26, 2011 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.
glennda Posted January 27, 2011 Author Posted January 27, 2011 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" 1
glennda Posted January 27, 2011 Author Posted January 27, 2011 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 January 27, 2011 Posted January 27, 2011 (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 January 27, 2011 by TheLibrarian Didn't read the entire thread...
Guest TheLibrarian Posted January 27, 2011 Posted January 27, 2011 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now