LChecker.com - Check your broken links!

by Manuel 2/16/2010 5:12:00 AM
Check this out: http://www.lchecker.com/

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Simple Async HTTP Request

by Manuel 7/24/2008 8:25:00 AM

Since .NET Framework 2.0 there is a very easy way to perform an asynchronous HTTP request and retrieve the result as a string.
The System.Net.WebClient class provides methods and events to handle this task in a very convenient way:


using System.Net; 

private void Button_Click(object sender, RoutedEventArgs e)
{
   string topic=this.SearchTextBox.Text;
   string url = "http://yourserver.com";
   WebClient client = new WebClient();
   client.DownloadStringCompleted +=
new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
   client.DownloadStringAsync(
new Uri(url));
}

void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
   if (e.Error == null)
   {
      string result = e.Result;
   }
}

Currently rated 3.0 by 2 people

  • Currently 3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

C# | ASP.NET

Remote Desktop Console

by Manuel 7/24/2008 5:03:00 AM

Windows XP:

Use your_computer_name / console

Windows Vista

Use your_computer_name /admin  

To simulate Ctrl-Alt-Del press Ctrl-Alt-End. Pressing Ctrl-Alt-Del will open the Task Manager on the local machine.

Reboot and restart:
- "shutdown" to shutdown
- "shutdown -r" to reboot
- "shutdown -i" to get a GUI
- "shutdown -l" to logoff

The MS client also allows Ctrl-Alt-Break to switch between viewing the session in a window and on the full screen.

To change the port number of the remote desktop server:
The setting for the Terminal Services port lives in the following registry key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TerminalServer\WinStations\RDP-Tcp
Open up Regedit, find this key, look for the the PortNumber value and change it to whatever you want.

To connect to a remote server with a non standard port (other than 3389):
Use the computer name, followed by a ":" and the port (e.g. www.mymachine.com:6789)

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Stuff

MOSS 2007: Open Office Documents - Login Prompt Appears

by Manuel 1/10/2008 3:51:00 AM

If you open an office document from a sharepoint 3.0 / moss 2007 site from the extranet, you will be asked for your credentials several times. Here is a summary of possible solutions and workarounds I found about this issue:

- Monday, January 07, 2008: A new hotfix is available which should solve the problem in a scenario without proxy. The KB-Number is 943280.

Note: After you run this command line against your site, you must toggle the Site and Surveys permissions to turn off Anonymous access. Then, turn on Anonymous access again. You must do this for the command to take effect on content that exists in the site.

- 11/07/2007: The following hotfixes have been released:

KB 941853 addresses the issue where "Automatically detect settings" was required to be enabled in order for the Automatic configuration script to be processed for WebDAV communication. With 941853 installed, the "Automatically detect settings" can be either enabled or not.

KB 941890 includes the fix from 941853 and in addition will assume (in an environment where no proxy server is configured in the IE settings) that a site that has no dots in the name will be treated as an intranet site (e.g. http://companyweb is intranet while http://www.mycompany.com is Internet) and credentials will be passed automatically for WebDAV communication.

- For IE7 the equivalent is adding the site to the Intranet Security Zone.

- Only NTLM can automatically send credentials

- Convert all Office documents to Adobe PDF. For documents that need to be available in the native Office format (.doc, .xls, .ppt, .vsd, etc.), compress them as .zip files. Use the .pdf and .zip files in the document libraries instead of native Office files.

- You can completely get around this by publishing your Sharepoint from behind an ISA 2006 server when in Form Based Authentication.

When you publish using Form Based Auth and select "Private Machine" at login, you will be given a cookie that both IE and Office will read that will authenticate you to the AD/Sharepoint for each request.

- Open Documents in Read-Only-Mode

RESOLUTION
To resolve this issue, do the following:
1. In Windows Explorer, find the Htmltransinfo.xml file. This file is located in the following folder:
<driveletter>:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\Template\Xml
2. Right-click Htmltransinfo.xml, and then click Edit.
3. Edit the file to set ProgId to empty (for example, ProgId = "").

The following is an example of how the Htmltransinfo.xml file looks before you make the edit:
<HtmlTrInfo>
<Mapping Extension="xls" AcceptHeader="application/vnd.ms-excel" HandlerUrl="HtmlTranslate.aspx" ProgId="SharePoint.OpenDocuments.2"/>
<Mapping Extension="doc" AcceptHeader="application/msword" HandlerUrl="HtmlTranslate.aspx" ProgId="SharePoint.OpenDocuments.2"/>
<Mapping Extension="ppt" AcceptHeader="application/vnd.ms-powerpoint" HandlerUrl="HtmlTranslate.aspx" ProgId="SharePoint.OpenDocuments.2"/>
<Mapping Extension="pps" AcceptHeader="application/vnd.ms-powerpoint" HandlerUrl="HtmlTranslate.aspx" ProgId=""/>
<Mapping Extension="one" AcceptHeader="" HandlerUrl="" ProgId="SharePoint.OpenDocuments.2"/>
</HtmlTrInfo>
The following is an example of how the Htmltransinfo.xml file looks after you make the edit to set ProgId to empty:

<HtmlTrInfo>
<Mapping Extension="xls" AcceptHeader="application/vnd.ms-excel" HandlerUrl="HtmlTranslate.aspx" ProgId=""/>
<Mapping Extension="doc" AcceptHeader="application/msword" HandlerUrl="HtmlTranslate.aspx" ProgId=""/>
<Mapping Extension="ppt" AcceptHeader="application/vnd.ms-powerpoint" HandlerUrl="HtmlTranslate.aspx" ProgId=""/>
<Mapping Extension="pps" AcceptHeader="application/vnd.ms-powerpoint" HandlerUrl="HtmlTranslate.aspx" ProgId=""/>
<Mapping Extension="one" AcceptHeader="" HandlerUrl="" ProgId=""/>
</HtmlTrInfo>
After you edit the Htmltransinfo.xml file, you can open Office documents in read-only mode on a Windows
SharePoint Services Web site that has its directory security set to anonymous access. You are not prompted
for authentication.

Currently rated 4.2 by 5 people

  • Currently 4.2/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , ,

MOSS 2007

Casino: Martingale ("Double On Loss") Strategy - Simulation

by Manuel 1/9/2008 5:23:00 AM

Do you know the Martingale strategy?
If not, have a look at http://de.wikipedia.org/wiki/Roulette_%28Gl%C3%BCcksspiel%29 (german) or http://en.wikipedia.org/wiki/Roulette (english).

If you still believe that this strategy could work, try out this small simulation software (in german, sorry, but therefor it's free of charge and you don't have to bet real money ;-)).

The simulation sets on a single change (red) and doubles it's bet on every lost round. Without a table limit and with unlimited money this strategy would work! But believe Albert Einstein who is reputed to have stated, "You cannot beat a roulette table unless you steal money from it.".

Currently rated 5.0 by 12 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , ,

Stuff

SQL Server Tweaks

by Manuel 12/21/2007 3:45:00 AM

Server’s free disk space:

xp_fixeddrives  


Determine logspace:
 

dbcc sqlperf (logspace)  


Tem
pDB size:

 sp_tempdbspace  


Current time and user information: 

select 
  
current_timestamp as Time
,
   user as Benutzer,

   system_user as System_Benutzer,

   current_user as Current_Benutzer
,
   session_user as Session_Benutzer
   


Monitoring SQL-Server: 

sp_who2 


Useful stored procedures: 

sp_helpdb -- Displays information about all databases on the server
sp_helpdb databasename -- Displays information about a particular database
sp_help objectname -- Displays information about a table
sp_spaceused -- Displays information about the space used in the current database
sp_tables -- Lists the tables in a database
sp_helptext name -- Displays the code used in a particular stored procedure
sp_dboption -- Sets or returns information about database options
    

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

SQL-Server

Switching the current asp.net user account programmatically

by Manuel 12/13/2007 9:51:00 AM

Sometimes it is necessary to change the user under whose account asp.net runs to execute a special method. This could be the case e.g. if you want to access an ADS with a local asp.net user and you get an error message "invalid username or password" (there is the possibility to pass a username and passwort, but that didn't work for me).

The usage of the class below is very simple:

...
Impersonation
imp = new Impersonation();
imp.ImpersonateValidUser(
"username", "domain", "password");
//execute your work here
imp.UndoImpersonation();
....




using
System;
using System.Security.Principal;
using System.Runtime.InteropServices;

namespace
Security
{

   public class Impersonation
   
{

      
public const int LOGON32_LOGON_INTERACTIVE = 2;
      
public const int LOGON32_PROVIDER_DEFAULT = 0;
      
WindowsImpersonationContext impersonationContext;

      [DllImport("advapi32.dll")]
      
public static extern int LogonUserA(String lpszUserName, 
         
String lpszDomain,
         
String lpszPassword,
         
int dwLogonType, 
         
int dwLogonProvider,
         
ref IntPtr phToken);
      
      [
DllImport("advapi32.dll", CharSet=CharSet.Auto, SetLastError=true)]
      
public static extern int DuplicateToken(IntPtr hToken, 
         
int impersonationLevel, 
         
ref IntPtr hNewToken);

 

      [
DllImport("advapi32.dll", CharSet=CharSet.Auto, SetLastError=true)]
      
public static extern bool RevertToSelf();

      [DllImport("kernel32.dll", CharSet=CharSet.Auto)]
      
public static extern bool CloseHandle(IntPtr handle);

      public bool ImpersonateValidUser(String userName, String domain, String password)
      {
         
WindowsIdentity tempWindowsIdentity;
         
IntPtr token = IntPtr.Zero;
         
IntPtr tokenDuplicate = IntPtr.Zero;
         
         
if(RevertToSelf())
         {
            
if(LogonUserA(userName, domain, password, LOGON32_LOGON_INTERACTIVE, 
               LOGON32_PROVIDER_DEFAULT,
ref token) != 0)
            {
               
if(DuplicateToken(token, 2, ref tokenDuplicate) != 0) 
               {
                  tempWindowsIdentity =
new WindowsIdentity(tokenDuplicate);
                  impersonationContext = tempWindowsIdentity.Impersonate();
                  
if (impersonationContext != null)
                  {
                     CloseHandle(token);
                     CloseHandle(tokenDuplicate);
                     
return true;
                  }
               }
            } 
         }
         if(token!= IntPtr.Zero) CloseHandle(token);
         
if(tokenDuplicate!=IntPtr.Zero) CloseHandle(tokenDuplicate);
         
return false;
      
}

      public void UndoImpersonation()
      {
         impersonationContext.Undo();
      }

   }
}

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

C# | ASP.NET

How to get information about tables and table columns in Oracle and SQL-Server?

by Manuel 12/13/2007 9:44:00 AM

Oracle

Get all tables including the system ones:
SELECT table_name FROM all_tables;

That will give you only the tables owned by the user that you are connecting as:
SELECT table_name FROM user_tables;

Query table columns:
SELECT * FROM all_tab_cols WHERE table_name = 'whatever table name you are looking for'

Looking for comments on the tables:
SELECT * FROM all_tab_comments WHERE table_name = 'whatever table name you are looking for'

SQL-Server

That will give you all tables:
SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE'

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

Oracle | SQL-Server

How to provide data global during a request (or where is the request context?) (ASP.NET)

by Manuel 12/13/2007 9:40:00 AM

You can save your data during a HttpRequest by passing it to System.Web.HttpContext.Current.Items[itemKey].
Objects stored in this Collection will be available during the whole lifecycle of the HttpRequest.

Example of usage:

System.Web.HttpContext.Current.Items["reloadCount"] = 5;

int reloadCount = (int) System.Web.HttpContext.Current.Items["reloadCount"];

Currently rated 5.0 by 2 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

C# | ASP.NET

How to read and write a DataSet from and to XML (C#)

by Manuel 12/13/2007 9:38:00 AM
private DataSet ReadDataSet(string dataPath)
{
   DataSet ds = new DataSet();
   ds.ReadXml(dataPath,
XmlReadMode.ReadSchema);
   return ds;
}

private void WriteDataSet(DataSet ds, string path)
{
   ds.WriteXml(path,
XmlWriteMode.WriteSchema);
}

Currently rated 5.0 by 2 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

C# | ASP.NET

Powered by BlogEngine.NET 1.2.0.0
Theme by Mads Kristensen

About the author

Name of author Author name
Something about me and what I do.

E-mail me Send mail

Calendar

<<  August 2010  >>
MoTuWeThFrSaSu
2627282930311
2345678
9101112131415
16171819202122
23242526272829
303112345

View posts in large calendar

Recent comments

Authors

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010

Sign in