Friday, September 25, 2009

Debugging Web Parts - a full explanation of the requirements

http://www.bluedoglimited.com/SharePointThoughts/ViewPost.aspx?ID=60

CallStack=true
debug=”true”
level=”Full”
mode=”Off” in the node

Wednesday, September 9, 2009

Customizing the Content Query Web Part and Custom Item Styles

http://www.heathersolomon.com/blog/articles/CustomItemStyle.aspx
http://blogs.edork.com/MikeGeyer/Lists/Posts/Post.aspx?ID=20

Tuesday, September 8, 2009

Test google.

google-analytics.

Tuesday, August 25, 2009

web part property

http://www.brightworkdemo.com/_vti_bin/help/1033/BrightWork/modify_a_web_part.htm

Monday, August 17, 2009

Get all Document Library List

0

This discards all items except those marked as Files/Documents.


CrossListQueryInfo clqi = new CrossListQueryInfo();
clqi.Query = @"0";
clqi.ViewFields = "";
clqi.Lists = "";
clqi.Webs = "";
clqi.UseCache = true;
clqi.RowLimit = (documentCount==0) ? 5 : (uint)documentCount;
CrossListQueryCache clqc = new CrossListQueryCache(clqi);
DataTable dt = clqc.GetSiteData(SPContext.Current.Site, CrossListQueryCache.ContextUrl());

Thursday, August 6, 2009

Stop Office Sharepoint Search server

pskill \\sharepointservername mssearch
Detail:
http://social.technet.microsoft.com/Forums/en-US/sharepointsearch/thread/9b313d05-73e3-4c3a-ac18-39fefaa4352a

PSTools Downloads:
http://technet.microsoft.com/en-us/sysinternals/dd443648.aspx

Sunday, August 2, 2009

CALM

http://elczara.spaces.live.com/blog/cns!554EC06D366AC9D5!681.entry

PARENT ELEMENT
ELEMENT
DESCRIPTION

Where Used within the context of a query to specify a filter.
And Used within the Where element to group filters in a query for a view.
Or Used within the Where element to group filters in a query.
BeginsWith Searches for a string at the start of a column that holds Text or Note field type values.
Contains Searches for a string anywhere within a column that holds Text or Note field type values.
Eq Arithmetic operator that means "equal to" and is used within a query.
Geq Arithmetic operator that means "greater than or equal to." This element can be used within a Where element in a query.
Gt Arithmetic operator that means "greater than." This element is used similarly to the Eq and Lt elements.
Leq Arithmetic operator that means "less than or equal to." The Leq element is used in view queries similarly to the Eq and Geq elements.
Lt Arithmetic operator that means "less than" and is used in queries in views. This element is used similarly to the Eq and Gt elements.
Neq Arithmetic operator that means "not equal to" and is used in queries.
DateRangesOvelap Used in queries to compare the dates in a recurring event with a specified DateTime value, to determine whether they overlap.
IsNotNull Used within a query to return items that are not empty (Null).
IsNull Used within a query to return items that are empty (Null).
OrderBy Determines the sort order for a query. The OrderBy element contains a group of FieldRef elements.
GroupBy Contains a Group By section for grouping the data returned through a query in a list view.



Thanks.

Wednesday, June 10, 2009

silde library

http://wm.microsoft.com/ms/gsd/mikegannotti/PowerPoint_2007_Slide_Libraries.wmv

Sunday, June 7, 2009

open edit document mode

Monday, June 1, 2009

WSS Field Names for Lists & Document Libraries

http://blog.thekid.me.uk/archive/2007/03/21/wss-field-display-amp-internal-names-for-lists-amp-document-libraries.aspx

Wednesday, May 27, 2009

hide show file vb script

Set sh = CreateObject("WScript.Shell")
theKey = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Hidden"
setHidden = sh.RegRead(theKey)

If setHidden = 1 Then
setHidden = 0
MsgBox "System and hidden files will no longer appear in Explorer.",64,"Hidden File Exchange"
Else
setHidden = 1
MsgBox "System and hidden files will appear in Explorer.",64,"Hidden File Exchange"
End If

sh.RegWrite theKey,setHidden,"REG_DWORD"
Set sh = Nothing

Thursday, May 14, 2009

How to Create Installer (.cab) for web part?

Error message when you try to upload a large file to a document library on a Windows SharePoint Services 3.0 site: "Request timed out"

http://support.microsoft.com/kb/925083

Monday, May 11, 2009

Get Current User Group

http://blogs.tamtam.nl/duarte/default,month,2008-12.aspx

   SPGroupCollection spGroups = 
SPContext.Current.Web.CurrentUser.OwnedGroups; 

            foreach (SPGroup group in spGroups) 
            { 
                output.Write(group.Name); 

                foreach (SPUser user in group.Users) 
                { 
                    output.Write(user.Name); 
                } 
            } 

Page web parts limit exceeded

Sometimes you might need to add more webparts to a certain page than the default MOSS limit, which is 50 webparts. If so in order to increase the limit follow the following procedure:

 

1. Go to the web.config file & open it.

2. Change the MaxZoneParts value to the new desired limit:

   

3. Save it & go.

Tuesday, May 5, 2009

Writing c# inline code in default.master

http://weblog.vb-tech.com/nick/archive/2006/08/03/1710.aspx
http://geekswithblogs.net/ferdous/archive/2008/09/25/125451.aspx

Rijndael Cryptography

http://www.obviex.com/samples/EncryptionWithSalt.aspx
http://www.obviex.com/samples/Encryption.aspx

How to encrypt and decrypt a file by using Visual C#

http://support.microsoft.com/kb/307010This article describes how to use the cryptography classes that are provided by the Microsoft .NET Framework to encrypt a text file to an unreadable state, and then to decrypt that text file back to its original format.
Back to the top
Requirements
loadTOCNode(2, 'summary');

The following list outlines the recommended hardware, software, network infrastructure, and service packs that you must have:
Microsoft Windows 2000 Professional, Windows 2000 Server, Windows 2000 Advanced Server, Windows NT 4.0 Server or Microsoft Windows XP Professional
Microsoft Visual Studio 2005 or Microsoft Visual Studio .NET
Back to the top
Encryption and decryption
loadTOCNode(2, 'summary');

The System.Security.Cryptographic namespace in the Microsoft .NET Framework provides a variety of tools to help you with encryption and with decryption. The CryptoStream class is one of the many classes that is provided. The CryptoStream class is designed to encrypt or to decrypt content as it is streamed out to a file.
Back to the top
Encrypt a file
loadTOCNode(2, 'summary');

To encrypt a file, follow these steps:
Start Visual Studio 2005 or Visual Studio .NET.
Click Visual C# under Projects, and then click Console Application under Templates. Visual C# .NET creates a Static class for you, together with an empty Main() procedure.
Use the using statement (as indicated in the sample code that follows) on the following namespaces:
System
System.Security
System.Security.Cryptography
System.Text
System.IOso that you do not have to qualify declarations from these namespaces later in your code. You must use these statements before any other declarations.
using System;
using System.IO;
using System.Security;
using System.Security.Cryptography;
using System.Runtime.InteropServices;
using System.Text;

Generate a secret key to encrypt and to decrypt the data. The DESCryptoServiceProvider is based on a symmetric encryption algorithm. The symmetric encryption requires a key and an initialization vector (IV) to encrypt the data. To decrypt the data, you must have the same key and the same IV. You must also use the same encryption algorithm. You can generate the keys by using either of the following methods:
Method 1 You can prompt the user for a password. Then, use the password as the key and the IV.
Method 2 When you create a new instance of the symmetric cryptographic classes, a new key and IV are automatically created for the session. Use the key and IV that are generated by the managed symmetric cryptographic classes to encrypt and to decrypt the file. For more information about how to generate and distribute keys, see the Microsoft .NET Framework SDK Documentation, or see the following Microsoft Developer Network (MSDN) Web site:
Generating keys for encryption and decryptionhttp://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpcongeneratingkeysforencryptiondecryption.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpcongeneratingkeysforencryptiondecryption.asp)
Add the following function to generate a new key for a session (as noted in Method 2 of step 4):
// Call this function to remove the key from memory after use for security.
[System.Runtime.InteropServices.DllImport("KERNEL32.DLL", EntryPoint="RtlZeroMemory")]
public static extern bool ZeroMemory(ref string Destination, int Length);

// Function to Generate a 64 bits Key.
static string GenerateKey()
{
// Create an instance of Symetric Algorithm. Key and IV is generated automatically.
DESCryptoServiceProvider desCrypto =(DESCryptoServiceProvider)DESCryptoServiceProvider.Create();
// Use the Automatically generated key for Encryption.
return ASCIIEncoding.ASCII.GetString(desCrypto.Key);
}
Create a method in your class that is named EncryptFile. The EncryptFile class must have the following three parameters:
sInputFilename
sOutputFilename
sKey (The secret key that is used to encrypt and decrypt the file.)
static void EncryptFile(string sInputFilename,
string sOutputFilename,
string sKey)

In the EncryptFile procedure, create an input FileStream object and an output FileStream object. These objects can be read from and written to the target files.
FileStream fsInput = new FileStream(sInputFilename,
FileMode.Open,
FileAccess.Read);
FileStream fsEncrypted = new FileStream(sOutputFilename,
FileMode.Create,
FileAccess.Write);

Declare an instance of the DESCryptoServiceProvider class. This represents the actual encryption and the actual decryption technology that is used on the files. At this point, you can create a different provider if you prefer to use RSAsecutiry or another cryptographic technique.
DESCryptoServiceProvider DES = new DESCryptoServiceProvider();

The cryptographic provider must be provided with your secret key as an array of bytes. The System.Text namespace provides a function that is named GetBytes(). As part of its encoding features, the GetBytes() function takes a string, and then returns an array of bytes. The size of the key is different for each cryptographic technique. For example, Data Encryption Standard (DES) takes a 64-bit key that is equal to 8 bytes or to 8 characters.If you do not provide a key, the provider randomly generates one. This successfully encrypts the file, but there is no way to decrypt the file. Note that you must also provide the initialization vector (IV). This value is used as part of the encryption. Like the key, the IV is randomly generated if you do not provide the value. Because the values must be the same for the encryption and the decryption, you must not permit random generation of these values.
DES.Key = ASCIIEncoding.ASCII.GetBytes(sKey);
DES.IV = ASCIIEncoding.ASCII.GetBytes(sKey);

Create an instance of the CryptoStream class by using the cryptographic provider to obtain an encrypting object (CreateEncryptor) and the existing output FileStream object as a part of the constructor.
ICryptoTransform desencrypt = DES.CreateEncryptor();
CryptoStream cryptostream = new CryptoStream(fsEncrypted,
desencrypt,
CryptoStreamMode.Write);

Read in the input file, and then write out to the output file. Pass through the CryptoStream object where the file is encrypted by using the key that you provided.
byte[] bytearrayinput = new byte[fsInput.Length - 1];
fsInput.Read(bytearrayinput, 0, bytearrayinput.Length);
cryptostream.Write(bytearrayinput, 0, bytearrayinput.Length);

Back to the top
Decrypt a file
loadTOCNode(2, 'summary');

To decrypt a file, follow these steps:
Create a method, and then name it DecryptFile. The decryption process is similar to the encryption process, however, the DecryptFile procedure has two key differences from the EncryptFile procedure.
CreateDecryptor is used instead of CreateEncryptor to create the CryptoStream object, that specifies how the object can be used.
When the decrypted text is written to the destination file, the CryptoStream object is now the source instead of the destination stream.
static void DecryptFile(string sInputFilename,
string sOutputFilename,
string sKey)
{
DESCryptoServiceProvider DES = new DESCryptoServiceProvider();
//A 64 bit key and IV is required for this provider.
//Set secret key For DES algorithm.
DES.Key = ASCIIEncoding.ASCII.GetBytes(sKey);
//Set initialization vector.
DES.IV = ASCIIEncoding.ASCII.GetBytes(sKey);
//Create a file stream to read the encrypted file back.
FileStream fsread = new FileStream(sInputFilename,
FileMode.Open,
FileAccess.Read);
//Create a DES decryptor from the DES instance.
ICryptoTransform desdecrypt = DES.CreateDecryptor();
//Create crypto stream set to read and do a
//DES decryption transform on incoming bytes.
CryptoStream cryptostreamDecr = new CryptoStream(fsread,
desdecrypt,
CryptoStreamMode.Read);
//Print the contents of the decrypted file.
StreamWriter fsDecrypted = new StreamWriter(sOutputFilename);
fsDecrypted.Write(new StreamReader(cryptostreamDecr).ReadToEnd());
fsDecrypted.Flush();
fsDecrypted.Close();
}

Add the following lines to the Main() procedure to call both EncryptFile and DecryptFile:
static void Main()
{
// Must be 64 bits, 8 bytes.
// Distribute this key to the user who will decrypt this file.
string sSecretKey;

// Get the key for the file to encrypt.
sSecretKey = GenerateKey();
// For additional security pin the key.
GCHandle gch = GCHandle.Alloc( sSecretKey,GCHandleType.Pinned );

// Encrypt the file.
EncryptFile(@"C:\MyData.txt",
@"C:\Encrypted.txt",
sSecretKey);
// Decrypt the file.
DecryptFile(@"C:\Encrypted.txt",
@"C:\Decrypted.txt",
sSecretKey);
// Remove the key from memory.
ZeroMemory(gch.AddrOfPinnedObject(), sSecretKey.Length * 2);
gch.Free();
}
Save the file. Run your application. Make sure that the path that is used for the input file name points to an existing file.
Test the procedure
loadTOCNode(3, 'summary');

Test this code with a text (.txt) file to confirm that the code encrypted and decrypted the file correctly. Make sure that you decrypt the file to a new file (as in the Main() procedure in this article) instead of to the original file. Examine the decrypted file, and then compare it to the original file.
Back to the top
Complete code listing
loadTOCNode(2, 'summary');

using System;
using System.IO;
using System.Security;
using System.Security.Cryptography;
using System.Runtime.InteropServices;
using System.Text;
namespace CSEncryptDecrypt
{
class Class1
{
// Call this function to remove the key from memory after use for security
[System.Runtime.InteropServices.DllImport("KERNEL32.DLL", EntryPoint="RtlZeroMemory")]
public static extern bool ZeroMemory(IntPtr Destination, int Length);

// Function to Generate a 64 bits Key.
static string GenerateKey()
{
// Create an instance of Symetric Algorithm. Key and IV is generated automatically.
DESCryptoServiceProvider desCrypto =(DESCryptoServiceProvider)DESCryptoServiceProvider.Create();
// Use the Automatically generated key for Encryption.
return ASCIIEncoding.ASCII.GetString(desCrypto.Key);
}
static void EncryptFile(string sInputFilename,
string sOutputFilename,
string sKey)
{
FileStream fsInput = new FileStream(sInputFilename,
FileMode.Open,
FileAccess.Read);
FileStream fsEncrypted = new FileStream(sOutputFilename,
FileMode.Create,
FileAccess.Write);
DESCryptoServiceProvider DES = new DESCryptoServiceProvider();
DES.Key = ASCIIEncoding.ASCII.GetBytes(sKey);
DES.IV = ASCIIEncoding.ASCII.GetBytes(sKey);
ICryptoTransform desencrypt = DES.CreateEncryptor();
CryptoStream cryptostream = new CryptoStream(fsEncrypted,
desencrypt,
CryptoStreamMode.Write);
byte[] bytearrayinput = new byte[fsInput.Length];
fsInput.Read(bytearrayinput, 0, bytearrayinput.Length);
cryptostream.Write(bytearrayinput, 0, bytearrayinput.Length);
cryptostream.Close();
fsInput.Close();
fsEncrypted.Close();
}
static void DecryptFile(string sInputFilename,
string sOutputFilename,
string sKey)
{
DESCryptoServiceProvider DES = new DESCryptoServiceProvider();
//A 64 bit key and IV is required for this provider.
//Set secret key For DES algorithm.
DES.Key = ASCIIEncoding.ASCII.GetBytes(sKey);
//Set initialization vector.
DES.IV = ASCIIEncoding.ASCII.GetBytes(sKey);
//Create a file stream to read the encrypted file back.
FileStream fsread = new FileStream(sInputFilename,
FileMode.Open,
FileAccess.Read);
//Create a DES decryptor from the DES instance.
ICryptoTransform desdecrypt = DES.CreateDecryptor();
//Create crypto stream set to read and do a
//DES decryption transform on incoming bytes.
CryptoStream cryptostreamDecr = new CryptoStream(fsread,
desdecrypt,
CryptoStreamMode.Read);
//Print the contents of the decrypted file.
StreamWriter fsDecrypted = new StreamWriter(sOutputFilename);
fsDecrypted.Write(new StreamReader(cryptostreamDecr).ReadToEnd());
fsDecrypted.Flush();
fsDecrypted.Close();
}
static void Main()
{
// Must be 64 bits, 8 bytes.
// Distribute this key to the user who will decrypt this file.
string sSecretKey;

// Get the Key for the file to Encrypt.
sSecretKey = GenerateKey();
// For additional security Pin the key.
GCHandle gch = GCHandle.Alloc( sSecretKey,GCHandleType.Pinned );

// Encrypt the file.
EncryptFile(@"C:\MyData.txt",
@"C:\Encrypted.txt",
sSecretKey);
// Decrypt the file.
DecryptFile(@"C:\Encrypted.txt",
@"C:\Decrypted.txt",
sSecretKey);
// Remove the Key from memory.
ZeroMemory(gch.AddrOfPinnedObject(), sSecretKey.Length * 2);
gch.Free();
}
}
}
Back to the top
REFERENCES
For more information about cryptography, and about using the cryptographic featu...
loadTOCNode(1, 'references');

For more information about cryptography, and about using the cryptographic features of .NET, see the following MSDN Web sites:
System.Security.Cryptography namespacehttp://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemsecuritycryptography.asp (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemsecuritycryptography.asp)
Microsoft .NET Framework Developer Centerhttp://msdn2.microsoft.com/en-us/netframework/default.aspx (http://msdn2.microsoft.com/en-us/netframework/default.aspx) For more general information about Visual C# .NET, see the following Usenet newsgroup:
microsoft.public.dotnet.languages.csharp (http://go.microsoft.com/fwlink/?linkid=5217)
Back to the top

Tuesday, April 28, 2009

Large-file-chunk-size: Stsadm property (Office SharePoint Server)

http://technet.microsoft.com/en-us/library/cc262061(TechNet.10).aspx

Description

Specifies the amount of data that can be read from the server running Microsoft SQL Server at one time.

NoteNote:

This property is available only from the command line.

Syntax

stsadm -o setproperty

-propertyname large-file-chunk-size

-propertyvalue

[-url ]

The syntax for the getproperty operation is:

stsadm -o getproperty

propertyname large-file-chunk-size

[-url ]

NoteNote:

You can substitute -pn for -propertyname and -pv for -propertyvalue.

Property values

The following table shows possible values.

Name

Value

propertyname

Gets or sets the name of the property.

propertyvalue

The upload size in bytes.

Content consisting of a single file or groups of files cannot be greater than this setting. The default value is 5 megabytes (MB). In certain circumstances, this value can be changed to any value up to 2 GB (2047 MB).

url

Typically, a path to the URL of the Web application, in the form http://server_name.

Remarks

If you have a file that is greater than your chunk size (for example, 70 megabytes (MB) when the chunk size is set to 5 MB), the file would be read in 14 chunks (70/5). The chunk size is not related to the maximum upload file size. The chunk size simply specifies the amount of data that can be read from a file at one time.

NoteNote:

If the chunk size is raised too high, the files might use up too much front-end memory and you may need to lower this setting

After making a change to this property, you must restart IIS. You can restart IIS by typing iisreset at a command-line prompt.

Examples

To set the large file chunk size to 500 MB, use the following syntax:

stsadm -o setproperty -pn large-file-chunk-size -pv 500

To view the current setting of the large file chunk size property, use the following syntax:

stsadm -o getproperty -pn large-file-chunk-size –url http://server_name

Max-file-post-size: Stsadm property (Office SharePoint Server)

http://technet.microsoft.com/en-us/library/cc261801.aspx

Description

Specifies the maximum allowable size for a single upload of content to any site.

This property is equivalent to the Maximum Upload Size user interface setting that is located on the Web Application General Settings page of the SharePoint Central Administration Web site.

Syntax

stsadm -o setproperty

-propertyname max-file-post-size

-propertyvalue

[-url http://server_name]

The syntax for the getproperty operation is:

stsadm -o getproperty

propertyname max-file-post-size

[-url ]

NoteNote:

You can substitute -pn for -propertyname and -pv for -propertyvalue.

Property values

The following table shows possible values.

Name

Value

propertyname

Gets or sets the name of the property.

propertyvalue

The upload size, in megabytes. Content, which can consist of a single file or groups of files, cannot greater than this setting. The default value is 50 megabytes (MB), but this can be changed to any value up to 2 gigabytes (GB) (2047 MB).

For example, if you plan on uploading large movie files with a file size over 50 MB, you would want to increase the value to an appropriate size greater than 50 MB.

url

Typically, a path to the URL of the Web application, in the form http://server_name.

Remarks

If a user tries to upload a file or group of files larger than the value specified by the max-file-post-size property, an error message appears and the user's files are not uploaded.

By default, the max-file-post-size property is set to 50 MB. If you notice performance or scale problems on the client or server, then you may need to adjust this setting to reach your target performance.

Examples

To set the upload size to 200 megabytes, use the following syntax:

stsadm -o setproperty -pn max-file-post-size -pv 200

To view the current setting of the maximum file post size property, use the following syntax:

stsadm -o getproperty -pn max-file-post-size –url http://server_name

Friday, April 17, 2009

Check If A Site Exists in SharePoint

/// Check to see if the site exists
///
/// If the site exists in the farm
private static bool CheckSiteExists(string siteName, string webName)
{
//open site and web
using (SPSite site = new SPSite(siteName))
{
using (SPWeb web = site.OpenWeb(webName))
{
//if the web does not exist return false
if (!web.Exists)
{
return false;
}
else //otherwise
return it does
{
return true;
}
}
}
}

Monday, April 13, 2009

Debug SharePoint

To debug the SharePoint, change the following web.config file

1:
2:
3:
4:

5:
6:
7:
8:

9:

Monday, April 6, 2009

Create User to the Domain and the Sharepoint.

Create User to Domain

Step 1: Open the “Active Directory Users and Computers”, Add the New User to PortalUser/Users Folder.


Step 2: Key in the user information.


Step 3: To check the password policy go to “Admintrator Tool ->Domain Security Policy->Security Setting->Account Policies->Password Policy”. All the password policy show at the lists.



Add or Syn the Active Directory User to the SharePoint.
Step 1: Open the SharePoint Central Administrator, go to SharedServices->User Profiles and Properties.

Step 2: Click the “Start Full Import” to import all the Active Directory user to the SharePoint or Click “Add User Profiles” to manually key in the new user Information.

Restart the Office SharePoint Services Search

Step 1: Go to Central Administration > Operations > Services On Server.



Step 2: Server: Select the server need restart the Office SharePoint Services Search.



Step 3: Stop Office Sharepoint Server Search.



Step 4: Start Office SharePoint Server Search.



Step 5: Select “Use this server for indexing content” and “use this server for serving search queries”.


Step 6: Key in Password after that click ok to proceed.

Step 7: Go to Central Administration > Shared Services Administration.

Step 8: Click the SSP and select edit properties from its drop down list.


Step 9: Enter the SSP process account password .

Step 10: Assign the index server and click Ok button.


Step 11: Go to Application Management > Manage search service, Make sure the “Shared Service Providers with Search Enabled” is up.


Completed Restart..........