Does anybody know if it is possible to pass an NT Environment variable to an SQL Server and then return the results back to the DOS?
Example: when a user logs in, their username is stored in the environment variable %USERNAME%. I would like to send this to SQL and then look up their department and then depending on what department they are in, different drives are mapped.
I think this would be done with stored procedures, but I am quite new to these.
Many thanks in advance
Matt CottrellYes I believe you can, try this from DOS, substring in your login criteria
isql -Uxx -Pxx -Sxx -n -Q"PRINT '%USERNAME%'"
You can then create a stored procedure that "PRINTS" out the drive mapping
"NET USE D: \\Server\Home "
Have your script file pass the USERNAME in then redirect the output to a file and run the file from the DOS command script
Example
isql -Uxx -Pxx -Sxx -n -Q"sp_MakeMappings '%USERNAME%'" -oC:\temp\mapping.cmd
C:\temp\mapping.cmd
del C:\temp\mapping.cmd
No comments:
Post a Comment