?
Solved

How to get login script stored in mssql database

Posted on 2009-12-16
1
Medium Priority
?
457 Views
Last Modified: 2013-11-21
Hi,

I want to put an entire login script in a sql database and then get it when the user login in the domain.

I tested write a script like this:

Set obj_Shell = CreateObject("WScript.Shell")
select.txt run sp for print out login script in text form
Set obj_WSH = obj_Shell.Exec("sqlcmd -h-1 -S 192.168.0.184\wdb11 -U xx -P xx -d loginscript -i select.txt")

Set obj_STDOUT = obj_WSH.StdOut
str_Output = obj_STDOUT.ReadAll
WScript.echo str_Output

'objFile.writeLine str_Output


Can I use sql database for storing login script in text form in the database? And get it from there, and run it when the user login?

Regards
//Peter
0
Comment
Question by:mholmen
1 Comment
 

Accepted Solution

by:
mholmen earned 0 total points
ID: 26061502
I figured out....:
'Start -----------------------------------------------
Set WSHNetwork = WScript.CreateObject("WScript.Network")
UserName = ""
UserName = WSHNetwork.UserName

On Error Resume Next
Set obj_Shell = CreateObject("WScript.Shell")

sql_query = "sqlcmd -h-1 -S 192.168.0.184\wdb11 -U xx -P xx -d loginscript -Q ""exec LongPrint """ + username + """"
Set obj_WSH = obj_Shell.Exec(sql_query )
Set obj_STDOUT = obj_WSH.StdOut
str_Output = obj_STDOUT.ReadAll

'WScript.Echo str_Output
Execute(str_Output)
'End ------------------------------------------------------------------------

The procedure I had to use, found at: http://blog.falafel.com/2007/02/28/TSQLExceedingThe8000ByteLimitOfThePRINTStatement.aspx
I neded this because the loginscript field vas more then 8000 characters.
0

Featured Post

Free recovery tool for Microsoft Active Directory

Veeam Explorer for Microsoft Active Directory provides fast and reliable object-level recovery for Active Directory from a single-pass, agentless backup or storage snapshot — without the need to restore an entire virtual machine or use third-party tools.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

My previous article  (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Server/Windows_Server_2008/A_4466-A-beginners-guide-to-installing-SCCM2007-on-Windows-2008-R2-Server.html)detailed one possible method to get SCCM 2007 installed an…
This is a fairly complicated script that will install the required prerequisites to install SCCM 2012 R2 on a server.  It was designed under the functional model in order to compartmentalize each step required, reducing the overall complexity.  The …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question