Comment transférer des noms de connexion et des mots de passe entre des instances de SQL Server – Serveur d’impression
Author: Titanfall —
Short summary: Pour transférer des noms de connexion et des mots de passe entre différentes versions de SQL Server, procédez comme suit: Exécutez le script suivant sur le serveur SQL source. Passez à l'étape 2 lorsque vous avez terminé de créer la procédure stockée sp_help_revlogin. ----- Début du script, création de la procédure sp_help_revlogin ----- UTILISER le […]
Quick overview
- Site
- Tutos GameServer
- Canonical URL
- https://tutos-gameserver.fr/2019/05/03/comment-transferer-des-noms-de-connexion-et-des-mots-de-passe-entre-des-instances-de-sql-server-serveur-dimpression/
- LLM HTML version
- https://tutos-gameserver.fr/2019/05/03/comment-transferer-des-noms-de-connexion-et-des-mots-de-passe-entre-des-instances-de-sql-server-serveur-dimpression/llm
- LLM JSON version
- https://tutos-gameserver.fr/2019/05/03/comment-transferer-des-noms-de-connexion-et-des-mots-de-passe-entre-des-instances-de-sql-server-serveur-dimpression/llm.json
- Manifest
- https://tutos-gameserver.fr/llm-endpoints-manifest.json
- Estimated reading time
- 4 minutes (196 seconds)
- Word count
- 652
Key points
- Pour transférer des noms de connexion et des mots de passe entre différentes versions de SQL Server, procédez comme suit: Exécutez le script suivant sur le serveur SQL source.
- Passez à l'étape 2 lorsque vous avez terminé de créer la procédure stockée sp_help_revlogin.
- ----- Début du script, création de la procédure sp_help_revlogin ----- UTILISER le maître ALLER SI OBJECT_ID ('sp_hexadecimal') N'EST PAS NULL DROP PROCEDURE sp_hexadecimal ALLER CREATE PROCEDURE sp_hexadecimal @binvalue varbinary (256), @hexvalue varchar (256) OUTPUT COMME DECLARE @charvalue varchar (256) DÉCLARE @i int DECLARE @length int DECLARE @hexstring char (16) SELECT @charvalue = '0x' SELECT @ i = 1 SELECT @length = DATALENGTH (@binvalue) SELECT @hexstring = '0123456789ABCDEF' PENDANT (@i 'sa' AUTRE DÉCLARER login_curs CURSEUR POUR SÉLECTIONNER le sid, nom, xstatus, mot de passe FROM master..sysxlogins O srvid EST NULL AND name = @login_name OPEN login_curs FETCH NEXT FROM login_curs INTO @SID_varbinary, @name, @xstatus, @binpwd SI (@@ fetch_status = -1) COMMENCER IMPRIMER 'Aucun identifiant trouvé.' FERMER login_curs DEALLOCATE login_curs RETOUR -1 FIN SET @tmpstr = '/ * sp_help_revlogin script' IMPRIMER @tmpstr SET @tmpstr = '** Generated' + CONVERT (varchar, GETDATE ()) + 'sur' + @@ SERVERNAME + '* /' IMPRIMER @tmpstr IMPRESSION '' IMPRIMER 'DECLARE @pwd sysname' PENDANT (@@ fetch_status -1) COMMENCER SI (@@ fetch_status -2) COMMENCER IMPRESSION '' SET @tmpstr = '- Login:' + @name IMPRIMER @tmpstr SI (@xstatus & 4) = 4 BEGIN - Compte / groupe authentifié par NT SI (@xstatus & 1) = 1 BEGIN - L'accès à la connexion NT est refusé SET @tmpstr = 'EXEC master..sp_denylogin' '' + @name + '' '' IMPRIMER @tmpstr FIN ELSE BEGIN - La connexion NT a un accès SET @tmpstr = 'Master EXEC..sp_grantlogin' '' + @name + '' '' IMPRIMER @tmpstr FIN FIN ELSE BEGIN - Authentification SQL Server SI (@binpwd N'EST PAS NUL) BEGIN - Mot de passe non nul EXEC sp_hexadecimal @binpwd, @txtpwd OUT SI (@xstatus & 2048) = 2048 SET @tmpstr = 'SET @pwd = CONVERT (varchar (256),' + @txtpwd + ')' AUTRE SET @tmpstr = 'SET @pwd = CONVERT (varbinary (256),' + @txtpwd + ')' IMPRIMER @tmpstr EXEC sp_hexadecimal @ SID_varbinary, @ SID_string OUT SET @tmpstr = 'EXEC master..sp_addlogin' '' + @name + '' ', @pwd, @sid =' + @SID_string + ', @encryptopt =' FIN ELSE COMMENCE - Mot de passe nul EXEC sp_hexadecimal @ SID_varbinary, @ SID_string OUT SET @tmpstr = 'EXEC master..sp_addlogin' '' + @name + '' ', NULL, @sid =' + @SID_string + ', @encryptopt =' FIN SI (@xstatus & 2048) = 2048 - login mis à jour de 6.5 SET @tmpstr = @tmpstr + '' 'skip_encryption_old' '' AUTRE SET @tmpstr = @tmpstr + '' 'skip_encryption' '' IMPRIMER @tmpstr FIN FIN FETCH NEXT FROM login_curs INTO @SID_varbinary, @name, @xstatus, @binpwd FIN FERMER login_curs DEALLOCATE login_curs RETOUR 0 ALLER ----- Fin du script ----- Après avoir créé la procédure stockée sp_help_revlogin, exécutez la procédure sp_help_revlogin à partir de l'Analyseur de requêtes sur le serveur source.
- La procédure stockée sp_help_revlogin peut être utilisée sur toutes les versions de SQL Server.
Structured content
Pour transférer des noms de connexion et des mots de passe entre différentes versions de SQL Server, procédez comme suit:
Exécutez le script suivant sur le serveur SQL source. Passez à l'étape 2 lorsque vous avez terminé de créer la procédure stockée sp_help_revlogin.
----- Début du script, création de la procédure sp_help_revlogin -----
UTILISER le maître ALLER SI OBJECT_ID ('sp_hexadecimal') N'EST PAS NULL DROP PROCEDURE sp_hexadecimal ALLER CREATE PROCEDURE sp_hexadecimal @binvalue varbinary (256), @hexvalue varchar (256) OUTPUT COMME DECLARE @charvalue varchar (256) DÉCLARE @i int DECLARE @length int DECLARE @hexstring char (16) SELECT @charvalue = '0x' SELECT @ i = 1 SELECT @length = DATALENGTH (@binvalue) SELECT @hexstring = '0123456789ABCDEF' PENDANT (@i 'sa' AUTRE DÉCLARER login_curs CURSEUR POUR SÉLECTIONNER le sid, nom, xstatus, mot de passe FROM master..sysxlogins O srvid EST NULL AND name = @login_name OPEN login_curs FETCH NEXT FROM login_curs INTO @SID_varbinary, @name, @xstatus, @binpwd SI (@@ fetch_status = -1) COMMENCER IMPRIMER 'Aucun identifiant trouvé.' FERMER login_curs DEALLOCATE login_curs RETOUR -1 FIN SET @tmpstr = '/ * sp_help_revlogin script' IMPRIMER @tmpstr SET @tmpstr = '** Generated' + CONVERT (varchar, GETDATE ()) + 'sur' + @@ SERVERNAME + '* /' IMPRIMER @tmpstr IMPRESSION '' IMPRIMER 'DECLARE @pwd sysname' PENDANT (@@ fetch_status -1) COMMENCER SI (@@ fetch_status -2) COMMENCER IMPRESSION '' SET @tmpstr = '- Login:' + @name IMPRIMER @tmpstr SI (@xstatus & 4) = 4 BEGIN - Compte / groupe authentifié par NT SI (@xstatus & 1) = 1 BEGIN - L'accès à la connexion NT est refusé SET @tmpstr = 'EXEC master..sp_denylogin' '' + @name + '' '' IMPRIMER @tmpstr FIN ELSE BEGIN - La connexion NT a un accès SET @tmpstr = 'Master EXEC..sp_grantlogin' '' + @name + '' '' IMPRIMER @tmpstr FIN FIN ELSE BEGIN - Authentification SQL Server SI (@binpwd N'EST PAS NUL) BEGIN - Mot de passe non nul EXEC sp_hexadecimal @binpwd, @txtpwd OUT SI (@xstatus & 2048) = 2048 SET @tmpstr = 'SET @pwd = CONVERT (varchar (256),' + @txtpwd + ')' AUTRE SET @tmpstr = 'SET @pwd = CONVERT (varbinary (256),' + @txtpwd + ')' IMPRIMER @tmpstr EXEC sp_hexadecimal @ SID_varbinary, @ SID_string OUT SET @tmpstr = 'EXEC master..sp_addlogin' '' + @name + '' ', @pwd, @sid =' + @SID_string + ', @encryptopt =' FIN ELSE COMMENCE - Mot de passe nul EXEC sp_hexadecimal @ SID_varbinary, @ SID_string OUT SET @tmpstr = 'EXEC master..sp_addlogin' '' + @name + '' ', NULL, @sid =' + @SID_string + ', @encryptopt =' FIN SI (@xstatus & 2048) = 2048 - login mis à jour de 6.5 SET @tmpstr = @tmpstr + '' 'skip_encryption_old' '' AUTRE SET @tmpstr = @tmpstr + '' 'skip_encryption' '' IMPRIMER @tmpstr FIN FIN FETCH NEXT FROM login_curs INTO @SID_varbinary, @name, @xstatus, @binpwd FIN FERMER login_curs DEALLOCATE login_curs RETOUR 0 ALLER ----- Fin du script -----
Après avoir créé la procédure stockée sp_help_revlogin, exécutez la procédure sp_help_revlogin à partir de l'Analyseur de requêtes sur le serveur source. La procédure stockée sp_help_revlogin peut être utilisée sur toutes les versions de SQL Server. La sortie de la procédure stockée sp_help_revlogin sont des scripts de connexion qui créent des connexions avec le SID et le mot de passe d'origine.
Maître EXEC..sp_help_revlogin
Exemple de sortie:
DECLARE @pwd sysname
- Identifiant: 71EDC628A9574AB7BEE1EA914F1A0A7E SET @pwd = CONVERT (varbinary (256), 0x01003069FE2D1BFBF6407872FA61BE9C669B632F05C458B2B9883AAA835EF208D28C84CFB753004C50D42C759D) Maître EXEC..sp_addlogin '71EDC628A9574AB7BEE1EA914F1A0A7E', @pwd, @sid = 0x2E8DF4909C0CEB4B8C8A49493414B759, @encryptopt = 'skip_encryption' - Login: admin SET @pwd = CONVERT (varbinary (256), 0x0100CA7C6475AC2FF8DC9247A785BFDC4EC0EA38620CAD2E2B0EF24A434708AA91793114CE0F394E0F4939EC013053E5) Maître EXEC..sp_addlogin 'admin', @pwd, @sid = 0x9FDF121BED431D4EB7EAC551F67D276A, @encryptopt = 'skip_encryption'
...
Enregistrez la sortie, puis collez-la et exécutez-la dans SQL Server Management Studio. sur le serveur SQL de destination.
Click to rate this post! [Total: 0 Average: 0]
Topics and keywords
Themes: Serveur d'impression
License & attribution
License: CC BY-ND 4.0.
Attribution required: yes.
Manifest: https://tutos-gameserver.fr/llm-endpoints-manifest.json
LLM Endpoints plugin version 1.1.2.