Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

31.8.09

How to show/hide webpart programmatically ?

Sometimes, we need to show and hide webparts programmatically based on some events. This can be done by the following code:

SPWeb myWeb = SPContext.Current.Web;
myWeb.AllowUnsafeUpdates = true;

Microsoft.SharePoint.WebPartPages.SPLimitedWebPartManager mgr = null;
mgr = myWeb.GetLimitedWebPartManager(
"default.aspx",
System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);
foreach (System.Web.UI.WebControls.WebParts.WebPart myWebPart in mgr.WebParts)
{
// If this is the webpart we want to change...
if (myWebPart.Title == "SomeWebpartName")
{
myWebPart.Hidden = true;
mgr.SaveChanges(myWebPart);
break;
}
}



Global Assembly Cache is Empty !


Problem:
When trying to build and copy to GAC, you see that GAC is empty !!!

Solution:
Restart the "indexing service".

Cannot open Office 2010 documents in sharepoint using Windows 7


Problem:
After installing Office 2010 you discover that it ahs no integration with Sharepoint, and it refuses to open any sharepoint document from it.

Solution:
1- Open Internet Explorer.
2- Go to "Tools".
3- Go to "Internet Options".
4- Click "LAN Settings" ubder "Connections" tab.
5- Check mark for "Use a proxy server for the LAN".
6- Specify 127.0.0.1 as the address.


17.1.09

Dependency Injection Pattern

Topic: Don’t Look For Things!
Speaker: Miško Hevery
Subject: Dependency Injection

Video:
 


Slides:

for more details: http://martinfowler.com/articles/injection.html


19.12.08

Subpixel Layout And Rendering

Gecko does subpixel layout and rounds coordinates to device pixels for rendering.

He's right that in some sense, when you have to render a CSS layout to a screen with discrete pixels, all the options are imperfect and browsers are choosing different imperfect options. However I think we need to explain the big picture a little better.

Gecko intentionally supports subpixel layout because for high resolution output devices, especially printers but also high-DPI screens that will become more common, one CSS "px" should be mapped to many device pixels, so you can in fact do sub-CSS-pixel rendering. For those devices, rounding layout units to CSS pixels is actually throwing away information and giving you a strictly worse layout than Gecko will give. For example, try printing in FF3 beta. You should see that in the printout (or generated PDF), no rounding has occurred and each child DIV looks identical.

Because this is important and we don't want layout to vary unnecessarily across devices, we do subpixel layout on all devices. When we have to draw to a regular-DPI screen, we then have to round the edges of drawn objects to the nearest screen pixel. This explains the results. Note that our approach of rounding at drawing time is optimal for avoiding gross layout changes due to rounding; it limits the impact of rounding to moving object edges by one pixel in some direction. It avoids gross layout changes like IE moving a DIV to the next line, or Safari leaving a 2px strip vacant at the end of the line. Thus I believe our approach is better than the alternatives in important ways.

The preceding paragraph is actually a slight oversimplification. We do have to do some rounding during layout simply due to the fact that computer arithmetic has limited precision. So during layout we round measurements to the nearest 1/60th of a CSS pixel. This number was chosen so that common fractions of a CSS pixel can be represented exactly. Note that rounding to 1/60th of a CSS pixel is far more benign than rounding to CSS pixels; 1/60th of a CSS pixel is approximately 1/5760th of an inch, not something most people are going to worry about!

In practice, we have seen very few Web compatibility issues caused by this scheme. Web authors should just not worry about the rounding, and should not attempt to round coordinates themselves. The new getBoundingClientRect and getClientRects APIs in FF3 can return fractional coordinates, just go with the flow. Feel free to position elements at those fractional boundaries, it will be lined up visually. If you insist on consistent rendering down to the pixel, then the only way to go is to specify px values for everything, including line-heights, and avoid percentage units. Or better still, use SVG. Or a PNG.

21.11.08

Flex in a week (47 video tutorial)

5.11.08

Add Copy To / Move To to the Windows Explorer Right Click Menu

A hidden functionality in Windows allows you to right click on a file, select Copy To Folder or Move To Folder, and the move to box will pop up and let you choose a location to either copy or move the file or folder to.

Here's the quick registry hack to get this working. As usual, back up your registry just in case. You will want to browse down to this key:

HKEY_CLASSES_ROOT\AllFilesystemObjects\shellex\ContextMenuHandlers

Once you are at that key, right click and choose the New Key option:

Now you will double-click on the (Default) value and enter the following:

{C2FBB630-2971-11D1-A18C-00C04FD75D13}

Click OK and continue.

If you want to enable Move To, you will repeat the same steps, except creating a new key named Move To, and using this value:

{C2FBB631-2971-11D1-A18C-00C04FD75D13}

Now when you right click on a file or folder, you should see the following options:

Let's click Copy To Folder just to see what happens….

And that's it. Useful!

1.11.08

Open PCs (WIN XP) protected by passwords.

  1. Power on the PC.
  2. Press CTRL+ALT+DEL
  3. Press CTRL+ALT+DEL, again
  4. Type in the user name field the word "Administrator"
  5. Leave the password field empty.
That's all !!

.SO extension

  • Extension: .so
  • Type: Unix Shared Library
  • Category: Development
  • Mime type: application/octet-stream
  • Description: SO file is an Unix Shared Library (Shared Object). A shared library is a library of functions or classes (for C/C++ programmers) that are compiled, linked, and stored separately from the clients (applications) that use them. The UNIX equivalent of a DLL file in Windows is a Shared Library (SO) file.

Kerberos

Kerberos is a computer network authentication protocol, which allows individuals communicating over a non-secure network to prove their identity to one another in a secure manner. It is also a suite of free software published by Massachusetts Institute of Technology (MIT) that implements this protocol. Its designers aimed primarily at a client-server model, and it provides mutual authentication — both the user and the server verify each other's identity. Kerberos protocol messages are protected against eavesdropping and replay attacks.

Kerberos builds on symmetric key cryptography and requires a trusted third party. Extensions to Kerberos can provide for the use of public-key cryptography during certain phases of authentication.


Description

Kerberos uses as its basis the Needham-Schroeder protocol. It makes use of a trusted third party, termed a key distribution center (KDC), which consists of two logically separate parts: an Authentication Server (AS) and a Ticket Granting Server (TGS). Kerberos works on the basis of "tickets" which serve to prove the identity of users.

The KDC maintains a database of secret keys; each entity on the network — whether a client or a server — shares a secret key known only to itself and to the KDC. Knowledge of this key serves to prove an entity's identity. For communication between two entities, the KDC generates a session key which they can use to secure their interactions.


Protocol

The security of the protocol relies heavily on participants maintaining loosely synchronized time and on short-lived assertions of authenticity called Kerberos tickets.

What follows is a simplified description of the protocol. The following abbreviations will be used:
  • AS = Authentication Server
  • TGS = Ticket Granting Server
  • SS = Service Server
  • TGT = Ticket Granting Ticket
Briefly, the client authenticates to AS using a long-term shared secret and receives a ticket from the AS. Later the client can use this ticket to get additional tickets for SS without resorting to using the shared secret. These tickets can be used to prove authentication to SS.

In more detail:

User Client-based Logon Steps:
  1. A user enters a username and password on the client machine.
  2. The client performs a one-way function (Hash mostly) on the entered password, and this becomes the secret key of the client/user.
Client Authentication Steps:
  1. The client sends a cleartext message to the AS requesting services on behalf of the user. Sample message: "User XYZ would like to request services". Note: Neither the secret key nor the password is sent to the AS.
  2. The AS checks to see if the client is in its database. If it is, the AS sends back the following two messages to the client:
    • Message A: Client/TGS Session Key encrypted using the secret key of the client/user.
    • Message B: Ticket-Granting Ticket (which includes the client ID, client network address, ticket validity period, and the client/TGS session key) encrypted using the secret key of the TGS.
  3. Once the client receives messages A and B, it decrypts message A to obtain the Client/TGS Session Key. This session key is used for further communications with TGS.
    (Note: The client cannot decrypt Message B, as it is encrypted using TGS's secret key.)
    At this point, the client has enough information to authenticate itself to the TGS.
Client Service Authorization Steps:
  1. When requesting services, the client sends the following two messages to the TGS:
    • Message C: Composed of the Ticket-Granting Ticket from message B and the ID of the requested service.
    • Message D: Authenticator (which is composed of the client ID and the timestamp), encrypted using the Client/TGS Session Key.
  2. Upon receiving messages C and D, the TGS retrieves message B out of message C. It decrypts message B using the TGS secret key. This gives it the "client/TGS session key". Using this key, the TGS decrypts message D (Authenticator) and sends the following two messages to the client:
    • Message E: Client-to-server ticket (which includes the client ID, client network address, validity period and Client/Server Session Key) encrypted using the service's secret key.
    • Message F: Client/server session key encrypted with the Client/TGS Session Key.
Client Service Request Steps:
  1. Upon receiving messages E and F from TGS, the client has enough information to authenticate itself to the SS. The client connects to the SS and sends the following two messages:
    • Message E from the previous step (the client-to-server ticket, encrypted using service's secret key).
    • Message G: a new Authenticator, which includes the client ID, timestamp and is encrypted using client/server session key.
  2. The SS decrypts the ticket using its own secret key to retrieve the Client/Server Session Key. Using the sessions key, SS decrypts the Authenticator and sends the following message to the client to confirm its true identity and willingness to serve the client:
    • Message H: the timestamp found in client's Authenticator plus 1, encrypted using the Client/Server Session Key.
  3. The client decrypts the confirmation using the Client/Server Session Key and checks whether the timestamp is correctly updated. If so, then the client can trust the server and can start issuing service requests to the server.
  4. The server provides the requested services to the client.

Drawbacks

  • Single point of failure: It requires continuous availability of a central server. When the Kerberos server is down, no one can log in. This can be mitigated by using multiple Kerberos servers and fallback authentication mechanisms.
  • Kerberos requires the clocks of the involved hosts to be synchronized. The tickets have a time availability period and if the host clock is not synchronized with the Kerberos server clock, the authentication will fail. The default configuration requires that clock times are no more than 10 minutes apart. In practice Network Time Protocol daemons are usually used to keep the host clocks synchronized.
  • The administration protocol is not standardized and differs between server implementations. Password changes are described in RFC 3244.
  • Since the secret keys for all users are stored on the central server, a compromise of that server will compromise all users' secret keys.
  • A compromised client will compromise the user's password