How do we enable SQL cache dependency in ASP.NET 2.0? - asp.net

I think there are some steps to enable SQL Cache Depdndency :
Enabling notifications, changes in web.xml and then using Cache Dependency object.
Please help how do I pass through them ?

Have a look at this post. It takes you through using the Aspnet_regsql.exe tool, which sets it up for you.
Here is an excerpt from the above post:
...To enable a cache dependency on a particular database, run this command:
aspnet_regsql.exe -S server -U user -P password -d database -ed
This creates a new table, AspNet_SqlCacheTablesForChangeNotification,
in the designated database. Next, several AspNet_SqlCacheXxxx stored procs
are created in the same database.
Then look at this post from MSDN for an overview, with lots of How-to links.

To enable a table for SQL cache dependency use, you'll need to first run the aspnet_regsql.exe tool from a command-line prompt, with these options:
aspnet_regsql -S servername -U login -P password -ed -d databasename -et -t tablename
If your table name contains a space, then wrap the table name in quotes e.g.
aspnet_regsql -S servername -U login -P password -ed -d databasename -et -t "table name"
In your web.config, you'll need to add a caching section:
<system.web>
<caching>
<sqlCacheDependency enabled = "true" pollTime = "60000" >
<databases>
<add name="northwind"
connectionStringName="Northwind"
pollTime="9000000"
/>
</databases>
</sqlCacheDependency>
</caching>
</system.web>
When you add an item into your Cache, you use the SqlCacheDependency object to set up the relationship between the cached object and the underlying table:
SqlCacheDependency dependency = new SqlCacheDependency("databasename", "tablename");
Cache.Add(key, object, dependency);

Related

What caches uses Alfresco and how to properly clean them?

After several experiments with business processes, I noticed that the old definitions of business processes somewhere is cached.
For example, I developed some business process, then installed the AMP file with it. I worked with it, and then decided to make some changes.
For this, I again assembled the AMP file and installed it:
[bykovan#docflow alfresco-community]$ sudo java -jar bin/alfresco-mmt.jar uninstall some-module-repo tomcat/webapps/alfresco.war
...
[bykovan#docflow alfresco-community]$ sudo java -jar bin/alfresco-mmt.jar install amps/some-module-repo-1.0-SNAPSHOT.amp tomcat/webapps/alfresco.war
...
But I don't see my changes after deploy! To make the change take effect I have to make quite a lot of extra work.
Sequence of actions:
1 Shutdown Tomcat
[bykovan#docflow alfresco-community]$ sudo ./alfresco.sh stop
2 Re-create the alfresco database
[bykovan#docflow alfresco-community]$ sudo -i -u postgres
[postgres#docflow ~]$ psql
psql (9.5.5)
postgres=#
postgres=# drop database alfresco;
...
postgres=# create database alfresco;
...
postgres=# alter database alfresco owner to alfresco;
...
postgres=# \q
[postgres#docflow ~]$ exit
3 Remove everything from alf_data
[bykovan#docflow alf_data]$ sudo rm -r *
4 Remove alfresco and share folders
[bykovan#docflow alfresco-community]$ sudo rm -r alfresco
[bykovan#docflow alfresco-community]$ sudo rm -r share
5 Start Tomcat
[bykovan#docflow alfresco-community]$ sudo ./alfresco.sh start
6 Wait until the database is initialized...
7 Set the administrator's password
SELECT
anp1.node_id, // paste to the update statement
anp1.qname_id, // paste to the update statement
anp1.string_value
FROM alf_node_properties anp1
INNER JOIN alf_qname aq1 ON aq1.id = anp1.qname_id
INNER JOIN alf_node_properties anp2 ON anp2.node_id = anp1.node_id
INNER JOIN alf_qname aq2 ON aq2.id = anp2.qname_id
WHERE aq1.local_name = 'password'
AND aq2.local_name = 'username'
AND anp2.string_value = 'admin';
UPDATE
alf_node_properties
SET
string_value='209c6174da490caeb422f3fa5a7ae634'
WHERE node_id=... and qname_id=...;
(where '209c6174da490caeb422f3fa5a7ae634' is NTLM-encoded string 'admin')
8 Restart Tomcat
9 Log-in as Admin with password admin, add users etc...
What caches uses Alfresco and how to properly clean them?
I use the following configuration:
Alfresco Share v5.2.d (r134641-b15, Aikau 1.0.101.3, Spring Surf
5.2.d, Spring WebScripts 6.13, Freemarker 2.3.20-alfresco-patched, Rhino 1.7R4-alfresco-patched, Yui 2.9.0-alfresco-20141223)
Alfresco Community v5.2.0 (r134428-b13) schema 10005
You can find temp files at this location
<<alfresco-community>>\tomcat\temp
and files are stored in alf_data
<<alfresco-community>>\alf_data
Axel Faust gave an exhaustive answer:
What caches uses Alfresco and how to properly clean them?
"Any caches that Alfresco uses are emptied / cleared when Alfresco is restarted... Generally you should NEVER have to work with the database directly. It is strongly discouraged and not supported by Alfresco in any way."
It solved my issue.

Artifactory: upload with api key (not password)

How would you upload an artifact to artifactory without using a password?
If I create a new user specific for uploads, that user by default doesn't git the 'upload' permission unless they are an administrator.
To upload with credentials
curl -u admin:'correct-horse-battery-staple' -T foo.zip
To upload with an api key
curl --header 'X-JFrog-Art-Api: 1234567890' -T foo.zip
Alternativly you can use the syntax <username:apikey>
curl -u admin:1234567890 -T foo.zip
https://www.jfrog.com/confluence/display/RTF/Artifactory+REST+API
You can create the api key on the user profile page.
See the various authentication options, including authentication using API key, in the JFrog CLI for Artifactory documentation page:
https://www.jfrog.com/confluence/display/CLI/CLI+for+JFrog+Artifactory
If you want to use .pypirc you can just put:
[distutils]
index-servers = local
[local]
repository: https://artifactory-url/repo
username: <username>
password: <api-key>
Then you can upload using python setup.py bdist_wheel upload -r local.
Though my user is an admin at the moment so it answers only the API key part of the question.
If you're looking at a nuget artifact, here's the one line CLI command below.
nuget push <your-package-name.nupkg> -source <artifactory-repo-url>/nuget-local/ -ApiKey <your-user-name>:<apikey>
It's buried in the jfrog documentation. I would think uploading other artifacts would follow a similar pattern.

Issues logging in ldap root DN

I almost been stuck a day on the following issue,
I installed LDAP using: apt-get install slapd
and use the following configuration:
include /etc/openldap/schema/core.schema
include /etc/openldap/schema/cosine.schema
include /etc/openldap/schema/inetorgperson.schema
include /etc/openldap/schema/nis.schema
allow bind_v2
loglevel 0
moduleload back_sbdb.la
database bdb
suffix "dc=test,dc=nl"
rootdn "cn=Directory Manager,dc=test,dc=nl"
rootpw test
directory /var/lib/ldap
index objectClass eq
index userPassword eq,pres
index givenName,mail,mobile,sn,title,cn,description eq,sub,pres
index displayName eq,sub,pres
index postalAddress,facsimileTelephoneNumber pres
access to *
by self write
by * read
and I then try to bind using
ldapsearch -D cn=Directory Manager,dc=test,dc=nl -w test
but I still recieve the error ldap_bind: Invalid Credentials (49)
Anyone has any idea or clues what this could be?
Thanks in forward
Try it using quotes like;
ldapsearch -D "cn=Directory Manager,dc=test,dc=nl" -w test
Space character in Directory Manager may cause the problem.
Edit: Also, are you sure you don't need -h -p parameters?
-h The host name of the directory server
-p The port number of the directory server
Edit2: Just figured out what is wrong. You are using rootpw unencrypted in your slapd config file. You should use an encrypted password created by slappasswd tools output. This may cause problems under special circumstances.
Check this link for details: http://www.centos.org/docs/5/html/Deployment_Guide-en-US/s1-ldap-quickstart.html
A few things you could try:
Turn on more verbose logging (loglevel 255), and see if anything shows up in the log file.
Verify that the server really is reading the configuration file you think by checking the access time on the slapd.conf file (ls -lu slapd.conf)
Try binding using an invalid dn (ldapsearch -D cn=no-such-user -w test) and see if the error message changes (if so, that confirms that the problem is with the password, not the dn).
Try man ldapsearch.
I'm not really sure on debian/ubuntu, but in FreeBSD you need to add a -x to use simple authentication instead of SASL. I think this might be your issue?
Also, you could use -W instead of passing the password plain text on the commmand line.

how to create super admin in my phpMyAdmin?

I just finished my website here I used ASP.net & MySQL.
I uploaded my website file all right.
But the problem is with my database. I create my database very will and I create all my tables but the problem is that I can't execute my stored procedure?
That is because i don't have the privileges to do this operation?
The error in phpMyAdmin is:
MySQL said:
#1227 - Access denied; you need the SUPER privilege for this operation
How can I fix this?
As MySQL root:
$ mysql -u root -p # ..or, if no password has been set..
$ mysql -u root
Run this command:
GRANT SUPER ON *.* TO user#localhost;
Further reading:
http://dev.mysql.com/doc/refman/5.1/en/grant.html

Invalid object name 'ASPState.dbo.ASPStateTempApplications' - Exception after renaming the ASPState Database

I have created new session database using the command (aspnet_regsql.exe -S -E -ssadd -sstype p) and it created DB called ASPState. Then I renamed it to something like E_ASPStateDB. I have configured the correct DB name in the sessionState connection string. But still it throws the exception Invalid object name 'ASPState.dbo.ASPStateTempApplications'
What i need to do, so that it will use the new database name?
I ran this on the db server that the site was connecting to and it solved it immediately.
USE [ASPState]
GO
DECLARE #return_value int
EXEC #return_value = [dbo].[CreateTempTables]
SELECT 'Return Value' = #return_value
GO
Since you renamed the DB you will have to regenerate the ASPnet session tables. Below is the solution to it.
To Remove, use following command: [open visual studion command prompt]
aspnet_regsql -ssremove -S [SERVER] -U [USER] -P [PWD] -d [DATABASE] -sstype c
Then add them again by following command
aspnet_regsql -ssadd -S [SERVER] -U [USER] -P [PWD] -d [DATABASE] -sstype c
You must modify the stored procedures because they invoke the tables with the database name and schema, as follows:
[ASPState].dbo.ASPStateTempApplications
you have to change it for
[E_ASPStateDB].dbo.ASPStateTempApplications
once you have registered a DB name using aspnet_regsql, you shall have to use the name you registered with. There is no point really to change the name afterwards. If you really want to use a name like E_ASPStateDB, why not delete the registration of ASPState first and then re-registering with the name E_ASPStateDB. It shall make your life easier

Resources