How would I go about using C# to programmatically determine whether a SQL Server 2000 backup file has been password protected?
+1
A:
There is no native password protection for SQL Server backup files. So I'd recommend something like this:
IF (1==1)
{
//It's not password protected
}
Just kidding. Which application are you using the "Password Protect" the backup files? You'll likely have to contact the application vendor.
Aaron Alton
2009-06-12 21:16:18
By "password protected," I should've said that the backup was created using the "WITH PASSWORD = 'password'" parameter. After a little bit more research I've realized that this parameter isn't actually encrypting the backup file, it's just requiring that the password be supplied any time the backup is manipulated.
Donut
2009-06-15 13:50:16
To be honest, you actually threw me off with the WITH PASSWORD bit - I haven't seen the syntax in forever. Keep in mind that it's going to be discontinued in the next version of SQL Server (see here http://msdn.microsoft.com/en-us/library/ms186865.aspx). I would just do a RESTORE FILELISTONLY on the file, and catch the output to determine whether it returned a filelist, or an error stating that the password needs to be supplied.
Aaron Alton
2009-06-15 14:10:08
Yes I was aware that it's going to be discontinued, I just have some existing backup files that may or may not have been created with the WITH PASSWORD option. Thanks for the RESTORE FILELISTONLY suggestion, that's what I was looking for!
Donut
2009-06-16 15:55:24