eXpandFramework / eXpand

DevExpress XAF (eXpressApp) extension framework. ๐—น๐—ถ๐—ป๐—ธ๐—ฒ๐—ฑ๐—ถ๐—ป.๐—ฒ๐˜…๐—ฝ๐—ฎ๐—ป๐—ฑ๐—ณ๐—ฟ๐—ฎ๐—บ๐—ฒ๐˜„๐—ผ๐—ฟ๐—ธ.๐—ฐ๐—ผ๐—บ, ๐˜†๐—ผ๐˜‚๐˜๐˜‚๐—ฏ๐—ฒ.๐—ฒ๐˜…๐—ฝ๐—ฎ๐—ป๐—ฑ๐—ณ๐—ฟ๐—ฎ๐—บ๐—ฒ๐˜„๐—ผ๐—ฟ๐—ธ.๐—ฐ๐—ผ๐—บ and ๐˜๐˜„๐—ถ๐˜๐˜๐—ฒ๐—ฟ @๐—ฒ๐˜…๐—ฝ๐—ฎ๐—ป๐—ฑ๐—ณ๐—ฟ๐—ฎ๐—บ๐—ฒ๐˜„๐—ผ๐—ฟ๐—ธ and or simply ๐—ฆ๐˜๐—ฎ๐—ฟ/๐˜„๐—ฎ๐˜๐—ฐ๐—ต this repository and get notified from ๐—š๐—ถ๐˜๐—›๐˜‚๐—ฏ
http://expand.expandframework.com
Microsoft Public License
222 stars 115 forks source link

SequenceGenerator Error when connection is not by SSPI #775

Closed CWolffIF closed 4 years ago

CWolffIF commented 4 years ago

If I connect ta Database with a connectionstring not based on SSPI I got an Error on SequenceGeneratorService.cs:Zeile 277

If you connect with SSPI there is no error. Maybe the password in the connectionstring is lost?

SequenceGeneratorService.cs:

    public static IObservable<IDataLayer> SequenceGeneratorDatalayer(this  IObjectSpaceProvider objectSpaceProvider) 
        => Observable.Defer(() => XpoDefault.GetDataLayer(objectSpaceProvider.GetConnectionString(),
            ((TypesInfo) objectSpaceProvider.TypesInfo).EntityStores.OfType<XpoTypeInfoSource>().First().XPDictionary, AutoCreateOption.None
        ).ReturnObservable()).SubscribeReplay()
            .TraceSequenceGeneratorModule();

The error occurred:

Type:       UnableToOpenDatabaseException
Message:    Fehler beim ร–ffnen der Datenbank. Verbindungszeichenfolge: 'Data Source=172.16.0.36;Initial Catalog=eJHCRS;User ID=eJHCRS;Pooling=False;'; Fehler: 'System.Data.SqlClient.SqlException (0x80131904): Fehler bei der Anmeldung fรผr den Benutzer "eJHCRS".

bei System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling, SqlAuthenticationProviderManager sqlAuthProviderManager) bei System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) bei System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions) bei System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) bei System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions) bei System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1 retry) bei System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource1 retry) bei System.Data.SqlClient.SqlConnection.Open() bei DevExpress.Xpo.DB.MSSqlConnectionProvider.CreateDataBase(IDbConnection conn) ClientConnectionId:d455f5f8-d7c7-42bc-877a-fd42829af5ef Fehlernummer (Error Number):18456,Status (State):1,Klasse (Class):14' Data: 0 entries Stack trace:

bei DevExpress.Xpo.DB.MSSqlConnectionProvider.CreateDataBase(IDbConnection conn) bei DevExpress.Xpo.DB.MSSqlConnectionProvider.CreateDataBase() bei DevExpress.Xpo.DB.ConnectionProviderSql..ctor(IDbConnection connection, AutoCreateOption autoCreateOption) bei DevExpress.Xpo.DB.MSSqlConnectionProvider..ctor(IDbConnection connection, AutoCreateOption autoCreateOption) bei DevExpress.Xpo.DB.MSSqlConnectionProvider.CreateProviderFromString(String connectionString, AutoCreateOption autoCreateOption, IDisposable[]& objectsToDisposeOnDisconnect) bei DevExpress.Xpo.XpoDefault.GetConnectionProvider(String connectionString, AutoCreateOption defaultAutoCreateOption, IDisposable[]& objectsToDisposeOnDisconnect) bei DevExpress.Xpo.XpoDefault.GetDataLayer(String connectionString, XPDictionary dictionary, AutoCreateOption defaultAutoCreateOption, IDisposable[]& objectsToDisposeOnDisconnect) bei DevExpress.Xpo.XpoDefault.GetDataLayer(String connectionString, XPDictionary dictionary, AutoCreateOption defaultAutoCreateOption) bei Xpand.XAF.Modules.SequenceGenerator.SequenceGeneratorService.<>c__DisplayClass34_0.b_0() in D:\a\1\s\src\Modules\SequenceGenerator\SequenceGeneratorService.cs:Zeile 277. bei System.Reactive.Linq.ObservableImpl.Defer`1..Run() in /_/Rx.NET/Source/src/System.Reactive/Linq/Observable/Defer.cs:Zeile 38.

apobekiaris commented 4 years ago

true xaf strips the password out I will see to it

expand commented 4 years ago

We will try to answer all questions that do not require research within 24hr. To prioritize cases that require research we use the following labels in order. For all other issues the posting time is respected.

  1. โ‡๏ธ Exclusive-Services
    1. โค Bronze Sponsor
    2. โค Sponsor
    3. โค Backer
    4. Installation
    5. ShowStopper
    6. Nuget
    7. Contribution
    8. BreakingChange
    9. ReproSample
    10. Deployment
    11. must-have

This case is prioritized.

CWolffIF commented 4 years ago

Hi, a had a 2nd project, there it works without problems (same structure of the connection string).

If I add "Persist Security Info=true" to the conection string, it works in the 1st project too, but in the 2nd project the add is not necessary.

Is there switch in XPO/XAF?

apobekiaris commented 4 years ago

from what i remember from the old implementation there was a special structure to support the SequenceGenerator. I had to get the connectionstring using reflection so it will return intact. This feature is never tested in the new package

apobekiaris commented 4 years ago

I need a sample to reproduce the problem, i tried this connectionstring but worked fine

Data Source=APO-BEK;Initial Catalog=Solution60;Integrated Security=SSPI;User ID=APO-BEK\Tolis;Password=mypass;

also looking at the source code the GetConnectionString method does not retrieve it from XAF rather from lower classes and should be intact

https://github.com/eXpandFramework/DevExpress.XAF/blob/1e6e610051aeb423d7fc1a995f084dbc9dca5ce5/src/Extensions/Xpand.Extensions.XAF/ObjectSpaceProviderExtensions/ObjectSpacePovideExtensions.cs#L8

apobekiaris commented 4 years ago

works fine as well

apobekiaris commented 4 years ago

Data Source=APO-BEK;Initial Catalog=Solution60;User ID=sa;Password=sa;

CWolffIF commented 4 years ago

The miraculous is, that in one projects it works but in the other not. Both old projects and the problem comes up with 20.1.701.4.

But if I add "Persist Security Info=true" to

Data Source=TestSQL;Initial Catalog=Test;User ID=sa;Password=xxxx;Persist Security Info=true

it works in both projects. So it seems to me that XPO/XAF deletes the password in one project and in the other not.

apobekiaris commented 4 years ago

adding Persist Security Info=true works for me also

XPO/XAF deletes the password in one project and in the other not.

i already mentioned to you previusly that the connectionstring is removed only from XAF and the SequenceGenerator does not use the XAF methods.

But since I cannot repro it I am unassigned for now

apobekiaris commented 4 years ago

fyi

this the xaf code that removes the password from the XPObjectSpaceProvider

        public String ConnectionString {
            get {
                IDataLayer dataLayer = this.dataLayer;
                if(dataLayer != null && dataLayer.Connection != null) {
                    return dataLayer.Connection.ConnectionString;
                }
                return RemovePassword(dataStoreProvider.ConnectionString);
            }
            set {
                SetDataStoreProvider(new ConnectionStringDataStoreProvider(value));
            }
        }

and the code that SequenceGenerator uses to get the connectionstring where we see that is ether from the connection or from the DataStoreProvider. So what is your DataStoreProvider? does by any chnace is to blame?

        public static string GetConnectionString(this IObjectSpaceProvider objectSpaceProvider){
            var connection = objectSpaceProvider.GetPropertyValue("DataLayer")?.GetPropertyValue("Connection");
            return (string) (connection != null ? connection.GetPropertyValue("ConnectionString")
                : ( objectSpaceProvider.GetPropertyValue("DataStoreProvider")).GetPropertyValue("ConnectionString"));
        }
CWolffIF commented 4 years ago

It runs with the add "Persist Security Info=true" and I can see no difference to other projects. So we can close the task.