I get only the logical drives for computer with
var searcher = new ManagementObjectSearcher("SELECT * FROM Win32_MappedLogicalDisk");
But I need all logical drives including user mapped logical drives.
Thanks
Urs
The problem was, I was running the programm in visual studio with admin rights. I this case the user mapped drives are not shown.
It works for admin also with
var drives = DriveInfo.GetDrives();
when the registry entry
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
EnableLinkedConnections
is set to DWORD (32 Bit) with value 1.
Related
I am upgrading old system that runs under Windows XP to Windows 10.
One of the application have been developped in MS Access XP linked to an Oracle Database (Oracle 9i - instant client ODBC driver 32bit).
My computer is in French, MS Access is in french.
When I run a SQL line :
SELECT LIST_NAME FROM WZ_LISTS_HD WHERE LIST_REL1 = 'Produit'
I get the following result :
Summary Access vs SQL Explorer Windows 10 vs Windows XP
In Windows 10 (access), I get a #Deleted for each record with a special character (in this case "è" or "é"). I try with an homemade SQL Explorer and I get no #Deleted but I don't have the special character.
In my old system (Windows XP) with my SQL explorer, I get the complete recordset with special characters.
Anyone have an idea how to work this out? Most of post about #Deleted is suggesting each database corrupt or "needed for db compaction". In my case, I can get the records with my old system without a problem. There is users working with the database everyday. Hence, database is ok.
"Compacting database" makes no sense since I don't use a mdb (Access main db files).
I tried changing my windows keyboard and language feature. Didn't work.
Once last thing, I've done the same upgrade (Windows XP -> Windows 7) for some user under Windows 7. Worked like a charm. No #Deleted record. It seems to be related to how Windows 10 handles language.
This is the TNSNAMES.ORA File content.
SYNDATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = serveur-oracle)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = oracle6)
)
)
The ODBC information goes as follow :
ODBC Screenshot
Here is the part of code that call the SQL request :
VBA Code
Any ideas are welcomed.
To use passthrough queries instead of normal recordsets:
Dim qd As DAO.QueryDef
Set qd = CurrentDb.CreateQuerydef("", "SELECT LIST_NAME FROM WZ_LISTS_HD WHERE LIST_REL1 = 'Produit'")
qd.Connect = CurrentDb.TableDefs("LIST_NAME").Connect 'Reuse the connect
Dim rs As DAO.Recordset
Set rs = qd.OpenRecordset(dbOpenSnapshot, dbReadOnly) 'Minimal chance to see weird things with snapshots
When using passthrough queries, the SQL needs to be valid for Oracle (PL/SQL) and not for Access. They are executed directly on the backend database, limiting the opportunity for Access to do weird stuff. You do need to use UPPER instead of UCASE, for example.
(I know SO has well over a dozen questions with the same/similar title and I promise I've already gone through every one of them to no avail. I might have missed one or two minor details but I suspect my problem could be something more deep rooted. Enough said for intro)
Anyway, I have a database (let's call it FooDB) that I restored from a backup database. I can do whatever I want with it using SQL Server 2012 Management Studio, including SELECT, INSERT, or DELETE on any of the record, columns, or tables.
What I'm having trouble with is when I try to run a simple query against the same database, I get the following error:
An error has occurred.","ExceptionMessage":"The SELECT permission was denied on the object 'BarTable', database 'FooDB', schema 'dbo'."
There's a lot more to the stack trace but I won't post it here unless necessary. I'm using Visual Studio 2012 Ultimate and in one of the class files I specified the connection string as follows:
using (SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;" +
"Initial Catalog=FooDB;" +
"Integrated Security=true;"))
{
con.Open();
using (SqlCommand command = new SqlCommand("SELECT TOP 3 * FROM BarTable", con))
using (SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
... // code in this block is not shown as it is irrelevant to the issue
}
}
}
Heeding to various suggestions I came across on SO, I tried the following:
In SQL Server Management Studio, I selected 'Security' -> 'Logins' -> Right-click on the Windows login name and open the 'Properties' dialog -> In 'Server Roles' page, I selected dbcreator, public, serveradmin, setupadmin, and sysadmin
While on the same 'Properties' dialog from above, I selected 'User Mapping' page, then checked the 'Map' checkbox for the database (FooDB), and assigned the following database role membership: db_accessadmin, db_backupoperator, db_datareader, db_datawriter, db_ddladmin, db_owner, db_securityadmin, and public
From the Object Explorer of the Server Management Studio, I selected 'Databases' -> 'FooDB' -> 'Security' -> 'Users' -> Then I right-clicked the Windows login name and selected 'Properties' to open the 'Database User' dialog. Then I selected 'Owned Schemas' page and checked db_backupoperator, db_datareader, and db_datawriter
While on the same dialog from above, I selected 'Membership' page, and checked db_accessadmin, db_backupoperator, db_datareader, db_datawriter, db_ddladmin, db_owner, and db_securityadmin
That's all I can think of at this moment. Again, from within the SQL Server Management Studio (after logging in with the same Windows Authentication and server name) I can do whatever I want to with the database. But from within my C# class, it seems I can connect to the database but I lack the privilege to perform any action.
This is something I've been wrestling with unsuccessfully for almost a week. What gives?
Is the server authentication set to SQL server and Windows Authentication mode?
To do so, right click on the SQLServer -> properties -> security.
Edit: Dint mean database, did mean the SqlServer
Have you tried running sp_change_users_login .
Sometimes when you restore a DB it creates new sid (security ids) for the users. When it does that, the DB user and the Server login look the same, but internally the sids don't match. sp_change_users_login will fix that.
Details on how to use the stored procedure can be found here:
https://msdn.microsoft.com/en-us/library/ms174378.aspx
Try this initially - you will have to edit it slightly to fit your user and login name:
EXEC sp_change_users_login 'update_one', 'YourDBUserName', 'YourServerLoginName';
I've tried adding registry entries at:
Hive: HKEY_CURRENT_USER
Key Path: Software\Policies\Microsoft\Internet Explorer\BrowserEmulation\PolicyList\
Value name: sub.companyname.com
Value data: sub.companyname.com
However in Internet Explorer 11 this method does not work as it seems the list has moved.
My.Computer.Registry.SetValue("Software\Policies\Microsoft\Internet Explorer\BrowserEmulation\PolicyList", "sub.companyname.com", "sub.companyname.com")
I had the same problem, but creating the registry key you mention works for me.
Have you tried creating the registry key by hand?
If you are running 32 bit IE 11, you must create the registry key in 32 bit registry hive, if you are running 64 bit IE 11 you bust create the registry key in 64 bit registry hive.
IE 11 32 bit on:
Win 32 bit -> HKEY_CURRENT_USER\Software\Policies...
Win 64 bit -> HKEY_CURRENT_USER\Wow6432Node\Software\Policies...
IE 11 64 bit on:
Win 32 bit -> Can't install IE 64 bit
Win 64 bit -> HKEY_CURRENT_USER\Software\Policies...
Remember:
If you have IE open when you create the registry key, you need to restart it.
The new domain allowed to use compatibility mode won't be displayed in compatibility view settings list.
It appears that under Windows 8.1 Enterprise/IE11 the entry is a binary one - this is where I see the entries added under Tools/compatibility View Settings in the registry on my system:
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\BrowserEmulation\ClearableListData
Look for a Binary value called UserFilter - it's a bit hard to read when you look into it but you can tell it holds your entries.
We have several sites we'll need to add to the list so most likely will export the list from a "master" computer then push it through Group Policy Preferences at least once for initial settings. Unsure how we'll script additional entries at this point so that when users add their "personal" settings we don't overwrite the value but append to it but one thing at a time I guess.
W7 – IE11
Hive: HKEY_CURRENT_USER
Key Path: Software\Policies\Microsoft\Internet Explorer\BrowserEmulation\DisableSiteListEditing
Right Click on DisableSiteListEditing
Modify
Change Value Data from 1 to 0
I've recently used our company's spare laptop (that has a general user set up) while mine was being repaired. I've checked the "Remember password" option in SQL Server Management Studio when logging in to the database.
I need to clear the login and password information that I have used to prevent the next person that will use the laptop from using my login names and passwords. How can I do this?
Another answer here also mentions since 2012 you can remove Remove cached login via How to remove cached server names from the Connect to Server dialog?. Just confirmed this delete in MRU list works fine in 2016 and 2017.
SQL Server Management Studio 2017 delete the file
C:\Users\%username%\AppData\Roaming\Microsoft\SQL Server Management Studio\14.0\SqlStudio.bin
SQL Server Management Studio 2016 delete the file
C:\Users\%username%\AppData\Roaming\Microsoft\SQL Server Management Studio\13.0\SqlStudio.bin
SQL Server Management Studio 2014 delete the file
C:\Users\%username%\AppData\Roaming\Microsoft\SQL Server Management Studio\12.0\SqlStudio.bin
SQL Server Management Studio 2012 delete the file
C:\Users\%username%\AppData\Roaming\Microsoft\SQL Server Management Studio\11.0\SqlStudio.bin
SQL Server Management Studio 2008 delete the file C:\Users\%username%\AppData\Roaming\Microsoft\Microsoft SQL Server\100\Tools\Shell\SqlStudio.bin
SQL Server Management Studio 2005 delete the file – same as above answer but the Vista path.
C:\Users\%username%\AppData\Roaming\Microsoft\Microsoft SQL Server\90\Tools\Shell\mru.dat
These are profile paths for Vista / 7 / 8.
EDIT:
Note, AppData is a hidden folder. You need to show hidden folders in explorer.
EDIT:
You can simply press delete from the Server / User name drop down (confirmed to be working for SSMS v18.0). Original source from https://blog.sqlauthority.com/2013/04/17/sql-server-remove-cached-login-from-ssms-connect-dialog-sql-in-sixty-seconds-049/ which mentioned that this feature is available since 2012!
This works for SQL Server Management Studio v18.0
The file "SqlStudio.bin" doesn't seem to exist any longer. Instead my settings are all stored in this file:
C:\Users\*********\AppData\Roaming\Microsoft\SQL Server Management Studio\18.0\UserSettings.xml
Open it in any Texteditor like Notepad++
ctrl+f for the username to be removed
then delete the entire <Element>.......</Element> block
that surrounds it.
EDIT:
An even easier and working solution for v18.0 (Preview 7) would be:
Go to the "Connect to Server" dialogue window:
Click the down-arrow icon marked green in the screenshot.
Use the arrow-keys on the keyboard to navigate up/down
Press the DEL key on keyboard to delete the entry.
Close the dialogue window and when you reopen it the entry will indeed be removed.
For those looking for the SSMS 2012 solution... see this answer:
Remove cached login 2012
Essentially, in 2012 you can delete the server from the server list dropdown which clears all cached logins for that server.
Works also in v17 (build 14.x).
In my scenario I only wanted to remove a specific username/password from the list which had many other saved connections I didn't want to forget. It turns out the SqlStudio.bin file others are discussing here is a .NET binary serialization of the Microsoft.SqlServer.Management.UserSettings.SqlStudio class, which can be deserialized, modified and reserialized to modify specific settings.
To accomplish removal of the specific login, I created a new C# .Net 4.6.1 console application and added a reference to the namespace which is located in the following dll: C:\Program Files (x86)\Microsoft SQL Server\130\Tools\Binn\ManagementStudio\Microsoft.SqlServer.Management.UserSettings.dll (your path may differ slightly depending on SSMS version)
From there I could easily create and modify the settings as desired:
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using Microsoft.SqlServer.Management.UserSettings;
class Program
{
static void Main(string[] args)
{
var settingsFile = new FileInfo(#"C:\Users\%username%\AppData\Roaming\Microsoft\SQL Server Management Studio\13.0\SqlStudio.bin");
// Backup our original file just in case...
File.Copy(settingsFile.FullName, settingsFile.FullName + ".backup");
BinaryFormatter fmt = new BinaryFormatter();
SqlStudio settings = null;
using(var fs = settingsFile.Open(FileMode.Open))
{
settings = (SqlStudio)fmt.Deserialize(fs);
}
// The structure of server types / servers / connections requires us to loop
// through multiple nested collections to find the connection to be removed.
// We start here with the server types
var serverTypes = settings.SSMS.ConnectionOptions.ServerTypes;
foreach (var serverType in serverTypes)
{
foreach (var server in serverType.Value.Servers)
{
// Will store the connection for the provided server which should be removed
ServerConnectionSettings removeConn = null;
foreach (var conn in server.Connections)
{
if (conn.UserName == "adminUserThatShouldBeRemoved")
{
removeConn = conn;
break;
}
}
if (removeConn != null)
{
server.Connections.RemoveItem(removeConn);
}
}
}
using (var fs = settingsFile.Open(FileMode.Create))
{
fmt.Serialize(fs, settings);
}
}
}
There is a really simple way to do this using a more recent version of SQL Server Management Studio (I'm using 18.4)
Open the "Connect to Server" dialog
Click the "Server Name" dropdown so it opens
Press the down arrow on your keyboard to highlight a server name
Press delete on your keyboard
Login gone! No messing around with dlls or bin files.
Delete entire node "Element" (inside "Connections" tree) from XML file, used by version 18 or higher.
C:\Users\%username%\AppData\Roaming\Microsoft\SQL Server Management Studio\18.0\UserSettings.xml
As gluecks pointed out, no more SqlStudio.bin in Microsoft SQL Server Management Studio 18. I also found this UserSettings.xml in C:\Users\userName\AppData\Roaming\Microsoft\SQL Server Management Studio\18.0. But removing the <Element> containing the credential seems not working, it comes right back on the xml file, if I close and re-open it again.
Turns out, you need to close the SQL Server Management Studio first, then edit the UserSettings.xml file in your favorite editor, e.g. Visual Studio Code. I guess it's cached somewhere in SSMS besides this xml file?! And it's not on Control Panel\All Control Panel Items\Credential Manager\Windows Credentials.
For SQL Server Management Studio 2008
You need to go C:\Documents and Settings\%username%\Application
Data\Microsoft\Microsoft SQL Server\100\Tools\Shell
Delete SqlStudio.bin
Delete:
C:\Documents and Settings\%Your Username%\Application Data\Microsoft\Microsoft SQL Server\90\Tools\Shell\mru.dat"
In XP, the .mru.dat file is in C:\Documents and Settings\Name\Application Data\Microsoft\Microsoft SQL Server\90\Tools\ShellSEM
However, removing it won't do anything.
To remove the list in XP, cut the sqlstudio bin file from C:\Documents and Settings\Name\Application Data\Microsoft\Microsoft SQL Server\100\Tools\Shell and paste it on your desktop.
Try SQL
If it has worked, then delete the sqlstudio bin file from desktop.
Easy :)
Select the Login drop down arrow. Delete the users from the list
I'm trying to write an application that will allow a non-administrator user to create virtual directories in IIS6. I've tried numerous different ways of impersonating a administrative account but nothing seems to work to create the virtual directory.
Here's some of what I've tried:
dim sDirPath as string = "IIS://remotehost/W3svc/1/root"
Dim de As DirectoryEntry = New DirectoryEntry()
de.Path = sDirPath
de.AuthenticationType = AuthenticationTypes.Secure
de.Username = tbxUsername.Text
de.Password = tbxPassword.Text
''Fails here
virtualId = CType(de.Invoke("Create", "IIsWebVirtualDir", dirName), DirectoryEntry)
Using the AccountAlias class from here:
aa.BeginImpersonation()
Try
dim sDirPath as string = "IIS://remotehost/W3svc/1/root"
Dim de As DirectoryEntry = New DirectoryEntry()
de.Path = sDirPath
de.AuthenticationType = AuthenticationTypes.Secure
''Fails Here
virtualId = CType(de.Invoke("Create", "IIsWebVirtualDir", dirName), DirectoryEntry)
Finally
aa.EndImpersonation()
End Try
what is the correct way to impersonate another user in winforms application that will allow me to create the virtual directory WITHOUT the user that's running the application being an administrator on the web server? I know this can be done, IIS manager allows you to use "connect as" checkbox to do it.
It's been a long time since I hit this problem so I may be remembering a few things wrong. But IIRC ...
The root directory of IIS is protected by an ACL that requires administrative privs in order to create a new directory. A simple impersonation likely will not fix this issue because I believe under the hood you are combining both COM and either RPC or Local RPC. Impersonation across COM boundaries is tricky in native code and very tricky from managed code. It's very likley that you are running into an issue in this area with your impersonation trick.
It is possible though to lift the restriction on the web server and have normal users create root directories in IIS. I outlined the process to do so in the following blog post
http://blogs.msdn.com/jaredpar/archive/2005/02/04/367137.aspx