Close Database Connection

Jan 25, 2010 at 7:38 PM

Hi, 

I'm not sure if I'm missing something obvious or not properly using the UserPermissionCache but I"m unable to close the database connection to my security store. This is how I create UserPermissionCache.

 

private NetSqlAzMan.Cache.UserPermissionCache UserPermissionsCache; // This is my permissions cache

 

        private void CreateContext()

        {

            pCTX = new NetSqlAzManAuthorizationContext

                    (DataAccessLayer.ConnectionStringManager.DefaultNetSqlAzManConnectionString,

                    Properties.Settings.Default.NetSqlAzManStoreName,

                    Properties.Settings.Default.NetSqlAzManApplicationName,

                    WindowsIdentity.GetCurrent(), true);

UserPermissionsCache = GetUserPermissionCache();

}

 

        private void CreateContext()
        {
            try
            {
                pCTX = new NetSqlAzManAuthorizationContext
                    (DataAccessLayer.ConnectionStringManager.DefaultNetSqlAzManConnectionString,
                    Properties.Settings.Default.NetSqlAzManStoreName,
                    Properties.Settings.Default.NetSqlAzManApplicationName,
                    WindowsIdentity.GetCurrent(), true);

        public NetSqlAzMan.Cache.UserPermissionCache GetUserPermissionCache()

        {

            if (UserPermissionsCache == null)

            {

                UserPermissionsCache = new

                    NetSqlAzMan.Cache.UserPermissionCache(pCTX.Storage, pCTX.StoreName, pCTX.ApplicationName, WindowsIdentity.GetCurrent(), true, false);

}

return UserPermissionsCache;

}

 

From that point on, I could not find a way to close the database connection when I wanted to dispose and recreate my storage, connection stayed open until I closed the winforms application.

                //pCTX.StorageCache.Storage.CloseConnection();

                //pCTX.StorageCache.Storage.Dispose();

                //UserPermissionsCache = null;

                //pCTX.StorageCache = null;

                //pCTX = null;

 

Thanks for any help.

 

Chris

 

Chris

 

Coordinator
Jan 25, 2010 at 9:25 PM

Hi,

when you build the cache …

UserPermissionCache(IAzManStorage storage, string storeName, string applicationName, WindowsIdentity windowsIdentity, bool retrieveAttributes, bool multiThreadBuild, params KeyValuePair<string, object>[] contextParameters)

Set the multiThreadBuild parameters to false … otherwise … all is built in an async-way …and the connection could steel open.

Regards,

Andrea.

__________________________________
Andrea Ferendeles
NetSqlAzMan Project Coordinator  
E-mail aferende@hotmail.com Web http://netsqlazman.codeplex.com