in

ASP.NET Weblogs

Tolga Koseoglu

January 2008 - Posts

  • Silverlight in MOSS 2007 (SP1)

    First, I am trying to list, most likely not in logical order, all the steps necessary. After that I will support each point with either code or a screen shot.

    1. Develop a custom web part "wrapper". Configure so it can be deployed within MOSS.
    2. Create a simple Silverlight project. The two important files are Page.xaml and Page.cs (the code-behind file for the .xaml file)
    3. In your MOSS IIS directory create two custom folders. One for the Silverlight project .dll (ClientBin) and one for the .xaml (Xaml) files. Set permission level rather high and "Script only" on the execution properties for the ClientBin.
    4. Copy the infamous Silverlight.js in the yet another custom folder called Silverlight.

    SilverlightMOSS_1

    Code:

    Web Part Wrapper:

    using System;

    using System.Data;

    using System.Configuration;

    using System.Web;

    using System.Web.Security;

    using System.Web.UI;

    using System.Web.UI.WebControls;

    using System.Web.UI.WebControls.WebParts;

    using System.Web.UI.HtmlControls;

    using Microsoft.SharePoint.WebPartPages;

    using System.ComponentModel;

    using System.Text;

     

    namespace thelobbyWebParts

    {

        public class wpSilverlight : System.Web.UI.WebControls.WebParts.WebPart

        {

            #region "Variable Declaration"

            private String sXaml = "Page.xaml";

            private const String sDefault = "";

            #endregion

     

            #region "Properties"

            [WebBrowsable(true), Personalizable(true)]

            public string Xaml

            {

                get

                {

                    return sXaml;

                }

                set

                {

                    sXaml = value;

                }

            }

            #endregion

         

            protected override void CreateChildControls()

            {

                try

                {

                    this.Page.ClientScript.RegisterClientScriptInclude("Silverlight", "/CustomResources/Silverlight/Silverlight.js");

                }

                catch { }           

            }

      

            protected override void Render(System.Web.UI.HtmlTextWriter writer)

            {           

                try

                {

                    //HTML DIV TO HOST THE SILVERLIGHT CONTENT                                                                          

                    writer.Write("<div id='SilverlightControlHost' />");

     

                    //SCRIPT START

                    writer.Write("<script language='javascript' type='text/javascript'>");

                  

                    //CREATE SILVERLIGHT OBJECT

                    writer.Write("Silverlight.createObject('/CustomResources/Xaml/" + this.Xaml.ToString() +"', document.getElementById('SilverlightControlHost'), 'AgControl1',");

                    writer.Write("{width:'600px', height:'600px', inplaceInstallPrompt:false, background:'#FFFFFF', isWindowless:'false', framerate:'24', version:'1.1'},");

                    writer.Write("{onError:null, onLoad:null},");

                    writer.Write("null);");

     

                    //ERROR HANDLING FUNTION

                    writer.Write("function OnErrorEventHandler(sender, errorArgs)");

                    writer.Write("{");

                    writer.Write("    var errorMsg = 'Silverlight Error:';");

                    writer.Write("    errorMsg += 'Error Type:    ' + errorArgs.errorType + '';");

                    writer.Write("    errorMsg += 'Error Message: ' + errorArgs.errorMessage + '';");

                    writer.Write("    errorMsg += 'Error Code:    ' + errorArgs.errorCode + '';");

                    writer.Write("    switch(errorArgs.errorType)");

                    writer.Write("    {");

                    writer.Write("        case 'RuntimeError':");

                    writer.Write("            if (errorArgs.lineNumber != 0)");

                    writer.Write("            {");

                    writer.Write("                errorMsg += 'Line: ' + errorArgs.lineNumber + '';");

                    writer.Write("                errorMsg += 'Position: ' +  errorArgs.charPosition + '';");

                    writer.Write("            }");

                    writer.Write("            errorMsg += 'MethodName: ' + errorArgs.methodName + '';");

                    writer.Write("            break;");

                    writer.Write("        case 'ParserError':");

                    writer.Write("            errorMsg += 'Xaml File:      ' + errorArgs.xamlFile      + '';");

                    writer.Write("            errorMsg += 'Xml Element:    ' + errorArgs.xmlElement    + '';");

                    writer.Write("            errorMsg += 'Xml Attribute:  ' + errorArgs.xmlAttribute  + '';");

                    writer.Write("            errorMsg += 'Line:           ' + errorArgs.lineNumber    + '';");

                    writer.Write("            errorMsg += 'Position:       ' + errorArgs.charPosition  + '';");

                    writer.Write("break;");

                    writer.Write("        default:");

                    writer.Write("            break;");

                    writer.Write("    }");

                    writer.Write("    alert(errorMsg);");

                    writer.Write("}");

     

                    writer.Write("</script>");

     

     

                   

                    this.RenderChildren(writer);

                }

                catch

                {

                }

     

            }

        }

    }

    Page.xml

    <Canvas xmlns="http://schemas.microsoft.com/client/2007"

            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

                xmlns:app="clr-namespace:thelobbySilverlightProject;assembly=/CustomResources/ClientBin/thelobbySilverlightProject.dll"

            x:Name="rootCanvas"

            Loaded="Page_Loaded"

            x:Class="thelobbySilverlightProject.Page;assembly=/CustomResources/ClientBin/thelobbySilverlightProject.dll"

            Width="1200"

            Height="800"  

            >

     

          <TextBlock x:Name="txtTest" Canvas.Left="100" Text="Hello Everyone from Silverlight Project" FontSize="20"></TextBlock>

     

    </Canvas>

    Page.cs

    using System;

    using System.Windows;

    using System.Windows.Controls;

    using System.Windows.Documents;

    using System.Windows.Ink;

    using System.Windows.Input;

    using System.Windows.Media;

    using System.Windows.Media.Animation;

    using System.Windows.Shapes;

    using System.Windows.Browser;

     

    namespace thelobbySilverlightProject

    {

        public partial class Page : Canvas

        {

            public void Page_Loaded(object o, EventArgs e)

            {

                // Required to initialize variables

                InitializeComponent();

     

                TextBlock txt = this.FindName("txtTest") as TextBlock;

                txt.Text = "I loaded in code-behind";

               

            }

     

        }

    }

    SilverlightMOSS_2 

    If you have any question just let me know. I didn't explicitly go through the web part configuration, since that is a entire post in itself.

    This post if for users who are already familiar with custom web part development in the SharePoint/MOSS environment.

    I am going to post about custom web part development later.

    As usual....Good Luck

    --tolga--

  • Asp.net web application times out on long running stored procedure

    If you are running a web application and you are processing a stored procedure that takes quite a while you might get a time out error. An easy way to fix this is to add "Connect Timeout=60" to your connection string in the web.config file. 60 is in seconds and just an example. Here is an example connection string.

    <connectionStrings>

         <add name="DatamartConnectionString"

    connectionString="Data Source=XXX;Initial Catalog=Datamart;User ID=XXX;Password=XXX; Connect Timeout=60;" providerName="System.Data.SqlClient" />

    </connectionStrings>

    Good luck

    --tolga--

  • Lost your Reporting Services source code?

    No worries...you can get them back (granted you have deployed them before). Simple go to your Report Server. (http://servername/ReportServer)...browse to the report you are missing. Find the properties tab. In the *General* section click *Edit*. This will trigger a download of the report. Done and Done!!!!

    ReportingServices_1

    Good luck

    --tolga--

  • MOSS 2007 SP1

    I went through a couple of SP1 upgrades. 9 out 10 times it works just like you might think. Below I list resources and important steps to consider when upgrading your MOSS 2007 environment to SP1. Later I will also talk about how to integrate custom web parts targeted at the .net 3.5 framework.

    1. MOSS 2007 SP1 installation

    1. Go into your central administration and turn off the "Web Application" service. 

    SP1_1

    2. Install the WSS SP1. For MOSS users this is very important. The WSS SP1 has to installed before the MOSS SP1.

    WSS SP1

    3. Install MOSS SP1.

    MOSS SP1

    4. Go back into Central Administration and turn the "Web Application" service back on.

    5. Go into your list of web application. Find "Delete Web Application". BE CAREFUL, ONLY DELETE IIS SITE NOT THE DATABASE.

    6. Create new web application...fill out all the stuff required.

    7. Find "Content Databases". Delete the content database of the just newly created web application.

    8. User stsadm.exe to add your original content database.

    A. Manually:

        %STSADM% -o addcontentdb -url %URL% -databasename %LOBBYDBNAME%

    B. Using a batch file:

        @SET STSADM="C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\STSADM.EXE"

        ECHO "START---------------------Create Web Application" (see step 6)
        %STSADM% -o extendvs -url %URL% -ownerlogin ohana\--- -owneremail tkoseoglu@watg.com -databaseserver %DBSERVER% -        databasename %DBNAME%

        ECHO "START---------------------Delete vanilla content database" (see step 7)
        %STSADM% -o deletecontentdb -url %URL% -databasename %DBNAME%

        ECHO "START---------------------Add original Content database" (see step 8; manual process)
       %STSADM% -o addcontentdb -url %URL% -databasename %ORIGINALCONTENTDBNAME%

    9. During this process changes the original content database is upgraded...once completed...you are done.

    Service Pack 1 for Windows SharePoint Services 3.0 and Office SharePoint Server 2007

    This white paper describes features that are included in Microsoft® Office SharePoint® Server 2007 Service Pack 1 (SP1) and Windows® SharePoint Services 3.0 Service Pack 1 (SP1). In addition, this paper provides some guidelines for planning your solutions to work with current and future versions of Microsoft SharePoint Products and Technologies.

    In this paper:

    · About Service Pack 1

    · Installing on Windows Server® 2008

    · ASP.NET AJAX support

    · New operations and properties for the Stsadm command line tool

    · Recommendations for 64-bit hardware

    About Service Pack 1

    Service Pack 1 includes support for Windows Server 2008 and Internet Information Services (IIS) 7, support for creating Web Parts by using AJAX, and new operations and properties for the Stsadm command line tool. Service Pack 1 also includes over 60 hotfixes across all areas of SharePoint Products and Technologies.

    For more information about Service Pack 1, see the Microsoft Knowledge Base articles summarizing Windows SharePoint Services SP1 (http://go.microsoft.com/fwlink/?LinkId=105672&clcid=0x409) and Office SharePoint Server 2007 SP1 (http://go.microsoft.com/fwlink/?LinkId=105673&clcid=0x409).

    For more information about installing Windows SharePoint Services SP1, see the Windows SharePoint Services Technical Library (http://go.microsoft.com/fwlink/?LinkId=105676&clcid=0x409).

    For more information about installing Office SharePoint Server SP1, see the Office SharePoint Server TechCenter (http://go.microsoft.com/fwlink/?LinkId=105675&clcid=0x409).

    Installation on Windows Server 2008

    Windows Server 2008 with IIS 7 enhances the administration experience of SharePoint Products and Technologies with improvements in manageability, performance, and security. As the final release of Windows Server 2008 draws closer, check the Office SharePoint Server Newly Published page (http://go.microsoft.com/fwlink/?LinkID=89171&clcid=0x409) for a white paper about these enhancements.

    You can install Windows SharePoint Services 3.0 with SP1 and Microsoft Office SharePoint Server 2007 with SP1 on Windows Server 2008. However, you cannot install either Windows SharePoint Services or Office SharePoint Server 2007 without SP1 on Windows Server 2008. To install on Windows Server 2008, use the slipstream version of the downloads -- the ones that include Service Pack 1.

    If your deployment of Windows SharePoint Services uses Windows Internal Database, you must install Windows Internal Database Service Pack 2 (SP2) before you upgrade to Windows Server 2008. Windows Internal Database SP2 is not available as of this writing, but it will be available from the Microsoft Download Center (http://go.microsoft.com/fwlink/?LinkId=105854&clcid=0x409) shortly after the release of Windows SharePoint Services SP1.

    Pre-release copies of Windows Server 2008 should not be used in production environments with a SharePoint Products and Technologies deployment without previous support agreements.

    For more information about installing Windows SharePoint Services on Windows Server 2008, see the Windows SharePoint Services Technical Library (http://go.microsoft.com/fwlink/?LinkId=105685&clcid=0x409). More content will be available as the release of Windows Server 2008 draws closer.

    For more information about installing Office SharePoint Server on Windows Server 2008, see the Office SharePoint Server Technical Library (http://go.microsoft.com/fwlink/?LinkId=105687&clcid=0x409). More content will be available as the release of Windows Server 2008 draws closer.

    ASP.NET AJAX compatibility and support

    Beginning with Windows SharePoint Services 3.0 SP1 and Office SharePoint Server 2007 SP1, developers can use AJAX to create custom Web Parts. Developers can create Web Parts for asynchronous post pack by using either the Microsoft AJAX 1.0 Control toolkit for Microsoft ASP.NET or the AJAX 1.0 Extensions for ASP.NET. See Microsoft Knowledge Base article 941955 (http://go.microsoft.com/fwlink/?LinkId=105778&clcid=0x409) for more detail on the workarounds necessary to add an UpdatePanel control to a Web Part allowing you to leverage the asynchronous AJAX postback. Note that. Service Pack 1 and the AJAX Extensions must first be installed and configured. Also, AJAX components are not included with Service Pack 1: You must download and install them separately.

    After you install the AJAX components and Service Pack 1, you can get help from Microsoft customer support for that configuration.

    New Stsadm operations and properties

    Windows SharePoint Services SP1 includes these new Stsadm command line tool operations:

    · Mergecontentdbs - Permits a site collection to be moved from one content database to another when the parameters souredatabasename and destinationdatabasename are specified. (http://go.microsoft.com/fwlink/?LinkId=105701&clcid=0x409)

    · Renamesite – Changes a URL of a host-named site collection to a new URL. (http://go.microsoft.com/fwlink/?LinkId=105700&clcid=0x409)

    Similarly, Office SharePoint Server 2007 SP1 includes two new operations for the Stsadm command line tool, as well as changes to the properties for the People Picker Web control:

    · Mergecontentdbs – Permits a site collection to be moved from one content database to another when the parameters souredatabasename and destinationdatabasename are specified. (http://go.microsoft.com/fwlink/?LinkId=105694&clcid=0x409)

    · Renamesite – Changes a URL of a host-named site collection to a new URL. (http://go.microsoft.com/fwlink/?LinkId=105695&clcid=0x409)

    · After you install Office SharePoint Server 2007 SP1 you can use the peoplepicker properties (http://go.microsoft.com/fwlink/?LinkId=105693&clcid=0x409) with setproperty and getproperty operations to define the scope of the People Picker Web control to an Active Directory® directory service organizational unit.

    Recommendations for 64-bit hardware

    Windows SharePoint Services 3.0 and Office SharePoint Server 2007 are the last SharePoint Products and Technologies versions able to run on 32-bit hardware and operating systems. Do take this into account in current and future hardware decisions: Buying 64-bit hardware today helps ensure that your environment can accommodate future requirements and helps you to take advantage of the performance and scale of 64-bit technologies.

    ===============================================================================

    ===============================================================================

    Application
    Documentation Type
    KB Article
    Description

    Windows SharePoint Services 3.0

    Windows SharePoint Services 3.0
    KB
    929360
    When you try to open, to edit, or to create a new document in a Microsoft Windows SharePoint Services 3.0 document library by clicking New Document, the New Document button does not work. You cannot create a new document.
    Additionally, Windows Internet Explorer stops responding when you try to check out an existing document in a Windows SharePoint Services 3.0 document library.

    Windows SharePoint Services 3.0
    KB
    931636
    When you try to delete a message in Windows SharePoint Services 3.0 programmatically, you receive a null reference exception message. Additionally, the following message is logged in the Application log:
    System.NullReferenceException was unhandled by user code
    Message="Object reference not set to an instance of an object."
    Source="Microsoft.SharePoint"

    Windows SharePoint Services 3.0
    KB
    931636
    When you try to show an error message in a Windows SharePoint Services 3.0 Web site programmatically by using the ItemCheckingIn() event, the custom error message text is not shown. Instead, you receive a garbled error message that may resemble the following error message:
    1!.512s!

    Windows SharePoint Services 3.0
    KB
    931637
    When you locate a Windows SharePoint Services 3.0 custom list in Outlook 2007, CPU usage as reported in Task Manager may reach 100%. Additionally, CPU usage does not decrease until you exit Outlook 2007

    Windows SharePoint Services 3.0
    KB
    932055
    You create a list that contains a custom field that has a custom field type on a Microsoft Windows SharePoint Services 3.0 Web site. When you try to edit the properties of the custom field on the FldEditEx.aspx page, you cannot select the values for the custom field. Instead, you see only the default text in the custom field.

    Windows SharePoint Services 3.0
    KB
    932056
    When you run multiple custom programs that use the BreakRoleInheritance function in the Windows SharePoint Services 3.0 object model, one or more of the custom programs do not finish successfully. Additionally, you find the following error message in the Application event log:
    [ date time ] [Error]Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT))

    Windows SharePoint Services 3.0
    KB
    932347
    Microsoft Windows SharePoint Services 3.0 currently does not comply with daylight saving time (DST) in Western Australia for the years 2006 to 2009.

    Windows SharePoint Services 3.0
    KB
    932922
    Consider the following scenario. You have a document library in Microsoft Windows SharePoint Services 3.0 that is enabled for different content types. Additionally, you specify a default value for a column in a specific content type.
    In this scenario, when you save a document to the document library, the default column value that you specified is saved to the document regardless of the content type of the document.

    Windows SharePoint Services 3.0
    KB
    932922
    Consider the following scenario. You have a document library in Microsoft Windows SharePoint Services 3.0 that is enabled for different content types. Additionally, you specify a default value for a column in a specific content type.
    In this scenario, when you save a document to the document library, the default column value that you specified is saved to the document regardless of the content type of the document.

    Windows SharePoint Services 3.0
    KB
    933138
    When you schedule manual scans of content in Microsoft Office SharePoint Server 2007 and in Microsoft Windows SharePoint Services 3.0, you cannot disable Microsoft Virus Scanning API (VSAPI) scans.

    Windows SharePoint Services 3.0
    KB
    934253
    When you view the properties of a document that is opened from a Microsoft Windows SharePoint Services 3.0 document library, the Web File Properties dialog box appears. However, when you view the Web File Properties dialog box, you may experience one or more of the following symptoms: • Hidden properties are unexpectedly visible.
    • The Content Type list is missing.
    • All document properties are visible. You would expect only the properties for the document's content type to be visible.
    • If a Schema.xml file has not been modified for a feature, the Web File Properties dialog box may be blank.

    Windows SharePoint Services 3.0
    KB
    934613
    You try to install a feature in a Microsoft Windows SharePoint Services 3.0 Web site that uses the UserSelectionMode attribute or the UserSelectionScope attribute for a column that has the "User" type. When you do this, you receive an error message that resembles the following error message:
    Feature definition with Id 50af2204-cb5a-46e2-abe0-73735129d1fc failed validation, file 'columns.xml', line 8, character 3: The 'UserSelectionMode' attribute is not allowed.

    Windows SharePoint Services 3.0
    KB
    934790
    You add two List Web Parts to a page of a Windows SharePoint Services 3.0 Web site. The second List Web Part is connected to receive data from the first List Web Part. When you click the option button for an item in the first List Web Part, only that list item appears in the second List Web Part as expected. However, if you sort the results of the first List Web Part and then click the option button for a different item in the list, all list items unexpectedly appear in the second List Web Part.

    Windows SharePoint Services 3.0
    KB
    934790
    You run an SQL query to change the properties for a user that you created on a Windows SharePoint Services 3.0 Web site. When you run the PeoplePicker tool to search for a user, the original user is unexpectedly found. You would expect the PeoplePicker tool to use the changes that you made to the user's properties when it searches for a user.

    Windows SharePoint Services 3.0
    KB
    934790
    You browse a Windows SharePoint Services 3.0 Web site that contains different language subwebs. When you search one language subweb for an item that does not exist, you receive an error message as expected in that language subweb. However, when you search for an item that does not exist in a different language subweb, you unexpectedly receive an error message in the first language subweb that you searched.

    Windows SharePoint Services 3.0
    KB
    934790
    When you use the ItemAdding event to add a new file to a Windows SharePoint Services 3.0 document library, the path of the document library folder cannot be found.

    Windows SharePoint Services 3.0
    KB
    934790
    When you upload a file to multiple Windows SharePoint Services 3.0 document libraries, an alert creation e-mail message is sent from the document libraries as expected. However, an alert notification e-mail message is sent from only one document library. You would expect an alert notification e-mail message to be sent from all the document libraries to which you uploaded the file.

    Windows SharePoint Services 3.0
    KB
    934790
    When you run a program that uses the SPWorkflowManager.ForceDehydrateHttpContextWorkflows() event to work with files that are saved in a Windows SharePoint Services 3.0 document library, the expected Web page is not displayed. Additionally, you receive the following error message:
    Service Unavailable

    Windows SharePoint Services 3.0
    KB
    934882
    When you send a file as an attachment to an e-mail message to a Microsoft Windows SharePoint Services 3.0 document library, the file is not put in the document library.

    Windows SharePoint Services 3.0
    KB
    935515
    The Owssup.dll file causes Microsoft Visual Studio 2005 to stop responding (hang) when you close a file.

    Windows SharePoint Services 3.0
    KB
    935605
    When you use the volume shadow copy service (VSS) reference writer (Spwriter.exe) in Windows SharePoint Services 3.0, one or more of the following issues may occur: • When the OnPostRestore event occurs in the VSS reference writer, the event tries to clear a variant that holds a safe array, even though the array was previously freed. This may cause the VSS reference writer to stop responding when you try to restore it.
    • The VSS reference writer reports a dependency to the search writer as MACHINENAME \logical path. However, if the search is local, the VSS reference writer should not use MACHINENAME in the path.
    • When the VSS reference writer uses a fully qualified domain name (FQDN) to identify the instance of the MSSQLSERVER, the VSS reference writer constructs an incorrect logical path of the computer that is running Microsoft SQL Server. The incorrect logical path does not include the correct MACHINENAME reference as part of the path.
    • The VSS reference writer reports a dependency to Microsoft SQL Server databases. This occurs even if the Microsoft SQL Server instance that is hosting those databases is offline.
    • When a restore process occurs on a computer that is also running search components, the VSS reference writer may cause the process to stop responding.

    Windows SharePoint Services 3.0
    KB
    935958
    Consider the following scenario. You create a site collection in Microsoft Windows SharePoint Services 3.0 that contains several sites. You configure the permissions of a document library in one of the sites to inherit permissions. This operation is successful and the document library inherits its permissions as expected.
    However, when you try to connect to a site in the site collection, you receive the following error message:
    HTTP 500 - Internal server error
    All sites in the site collection are inaccessible.

    Windows SharePoint Services 3.0
    KB
    936867
    You remove users from the site collection for Microsoft Office SharePoint Server 2007. Then, you run a Microsoft Office SharePoint Server 2007 deployment job. After you update the page, the Status column for the deployment job shows a status of Failed. Additionally, when you click the Failed status link, you receive the following error message:
    User cannot be found.
    at Microsoft.SharePoint.SPUserCollection.GetByID(Int32 id)
    at Microsoft.SharePoint.SPWeb.get_Author()
    at Microsoft.SharePoint.Deployment.WebSerializer.GetDataFromObjectModel(Object obj, SerializationInfo info, StreamingContext context)
    at Microsoft.SharePoint.Deployment.DeploymentSerializationSurrogate.GetObjectData(Object obj, SerializationInfo info, StreamingContext context)
    at Microsoft.SharePoint.Deployment.XmlFormatter.SerializeObject(Object obj, ISerializationSurrogate surrogate, String elementName, Boolean bNeedEnvelope)
    at Microsoft.SharePoint.Deployment.XmlFormatter.Serialize(Stream serializationStream, Object topLevelObject)
    at Microsoft.SharePoint.Deployment.ObjectSerializer.Serialize(DeploymentObject deployObject, Stream serializationStream)
    at Microsoft.SharePoint.Deployment.SPExport.SerializeObjects()
    at Microsoft.SharePoint.Deployment.SPExport.Run()

    Windows SharePoint Services 3.0
    KB
    936867
    You upload documents to a document library on a server that is running Windows SharePoint Services 3.0 and Microsoft Forefront Security for SharePoint. In Central Administration, you click to clear the Scan documents on download check box on the Antivirus page. You click to select the Scan documents on download check box, and then you click OK. When you open the Application event log, you find the following error message:
    Source: Windows SharePoint Server
    Type: Error
    User: N/A
    Date: date
    Time: time
    Computer: computer_name
    Category: General
    Event ID: 26424
    Description: The description for Event ID ( 26424 ) in Source ( Windows SharePoint Services 3 ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. You may be able to use the /AUXSOURCE=flagto retrieve this description; see Help and Support for details. The following information is part of the event: #960012: Finished loading antivirus scanner. Error -2147024890

    Windows SharePoint Services 3.0
    KB
    936867
    You use a relative path in a link that is inside a Web Part. The Web Part is contained on a Web page on a server that is running Windows SharePoint Services 3.0. When you click OK to close the Web Part Properties dialog box, you notice the following error message on the Web page in the location of the Web Part:
    Error (File Not Found)
    Additionally, the relative path of the link in the Web Part is removed if you edit the Web Part again.

    Windows SharePoint Services 3.0
    KB
    936867
    You create a user account in a Windows SharePoint Services 3.0 site. If you click to clear the option to send the new user an e-mail message after you create the user's account, an e-mail message that contains the user name and password is sent unexpectedly to the user.

    Windows SharePoint Services 3.0
    KB
    936867
    You export a document from a document library on a server that is running Windows SharePoint Services 3.0. If the document contains a version history, the content of the Modified By field is lost when the document is imported back into the document library.

    Windows SharePoint Services 3.0
    KB
    937038
    Consider the following scenario. You create a site collection in Microsoft Windows SharePoint Services 3.0 that contains several sites. You configure the permissions of a document library in one of the sites to inherit permissions. This operation is successful and the document library inherits its permissions as expected.
    However, when you try to connect to a site in the site collection, you receive the following error message:
    HTTP 500 - Internal server error
    All sites in the site collection are inaccessible.

    Windows SharePoint Services 3.0
    KB
    937203
    You add a mapping for a Lotus Notes server to the "Server Name Mappings" search settings in Shared Services Administration. The mapping converts http:// URLs to Notes:// URLs in the search results. However, when the Lotus Notes server is crawled, the search results still display an http:// URL instead of a Notes:// URL. Additionally, the following error message is logged in the crawl log:
    Unknown Lotus Notes Error: Cannot get document for category or total entry.
    If you turn on the Lotus Notes Web Access feature to enable the link to be opened directly in the search results, some functions of the link may not display or may not work as expected.

    Windows SharePoint Services 3.0
    KB
    937203
    You save a Microsoft Office Excel workbook that contains a protected worksheet to a document library. When you search the title of Excel workbooks in the document library, the workbook or a link to the workbook is not listed in the search results.

    Windows SharePoint Services 3.0
    KB
    937498
    Servers that run Microsoft Windows SharePoint Services 3.0 together with Microsoft Office Live services can now track Windows Live ID user accounts by using the the Passport User ID (PUID) feature.

    Windows SharePoint Services 3.0
    KB
    937901
    When you try to delete a Computed type of field in a document library or in a list, the field is not removed. Instead, you receive the following error message:
    One or more field types are not installed properly. Go to the list settings page to delete these fields.
    Additionally, if you use the list settings page to delete the field, you experience the same symptoms.

    Windows SharePoint Services 3.0
    KB
    937901
    Consider the following scenario. You have a standard root-site of a site collection that contains the following three standard groups: • RootSiteName Members
    • RootSiteName Owners
    • RootSiteName Visitors
    You create a template that is based on the root-site. Then, you create a subsite that is based on the template. Later, if you delete the subsite, the three standard groups together with all members are also deleted.

    Windows SharePoint Services 3.0
    KB
    937901
    You have a document library that contains more than 1,000 documents that have unique permissions. When the document library is crawled, you receive an error message from the Site Data Web Service that resembles the following error message:
    <?xml version="1.0" encoding="utf-8" ?>
    - <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    - <soap:Body>
    - <soap:Fault> <faultcode>soap:Server</faultcode> <faultstring>Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.</faultstring>
    - <detail>
    <errorstring xmlns="http://schemas.microsoft.com/sharepoint/soap/">Value cannot be null. Parameter name: b</errorstring>
    </detail>
    </soap:Fault>
    </soap:Body>
    </soap:Envelope>

    Windows SharePoint Services 3.0
    KB
    938183
    You have the Content Approval feature enabled for a custom list on a Windows SharePoint Services 3.0 Web site. If you edit a list item that contains an attachment, the attachment disappears.

    Windows SharePoint Services 3.0
    KB
    938241
    When you use the "Email a Link" feature on a Windows SharePoint Services 3.0 Web site, a hyperlink to a document may not work as expected. This problem occurs if the following conditions are true: • The site URL contains a dash (-) character or a period (.) character.
    • You specify the name of the server by using a fully qualified domain name (FQDN).

    Windows SharePoint Services 3.0
    KB
    938499
    An external storage API is available for Windows SharePoint Services 3.0

    Windows SharePoint Services 3.0
    KB
    938536
    Search results are listed in an incorrect order when you click "View by Modified Date"
    You search for content in a list in Microsoft Office SharePoint Server 2007. Then, you click View by Modified Date to sort the search results by the date that the items were last modified. However, when you view the search results, items are listed in an incorrect order. You experience this issue after the crawler performs an incremental crawl of the content.
    This problem occurs in scenarios in which the incremental crawl incorrectly processes the time that the items were last modified.

    Windows SharePoint Services 3.0
    KB
    938536
    The last-modified date of items in the search results are displayed incorrectly as either yesterday's date or tomorrow's date
    You search for content in SharePoint Server 2007. When you view the search results, the date that is displayed as the date that the items were last modified is incorrect. The last-modified date is incorrectly displayed as either yesterday's date or tomorrow's date.
    This problem occurs in scenarios in which the conversion of the last-modified date and last-modified time from Coordinated Universal Time (UTC) to local time is processed incorrectly.

    Windows SharePoint Services 3.0
    KB
    938536
    Language-specific special characters are displayed incorrectly on Web pages of the destination site collection after you run a content deployment job
    You run a content deployment job to copy content from a source site collection to a destination site collection. Web pages in the source site collection have one or more columns that contain certain language-specific special characters such as ó or ê. After you run the content deployment job, you notice that the special characters are displayed incorrectly in Web pages of the destination site collection. You also experience this issue if you use the Stsadm.exe command-line tool to export content or to import content.
    This problem occurs if the special characters are encoded incorrectly.

    Windows SharePoint Services 3.0
    KB
    938569
    When the database status for a Microsoft Windows SharePoint Services 3.0 site collection has been set to offline, you may be unable to find items that are saved in the site collection when you search for them.

    Windows SharePoint Services 3.0
    KB
    938663
    When you use SharePoint 3.0 Central Administration to schedule a one-time timer job in Microsoft Windows SharePoint Services 3.0 during daylight saving time (DST), the job may be delayed by at least one hour. For example, you may experience the following symptoms: • You click Perform a backup to set up a backup operation. However, the backup job is delayed. It takes at least one hour before the backup job starts. If you include indexes in the backup, it may take two hours before the backup job starts.
    • You click Restore from backup to set up a restore operation from a backup. However, the restore job is delayed. It takes at least one hour before the restore job starts.

    Windows SharePoint Services 3.0
    KB
    939035
    Microsoft Windows SharePoint Services 3.0 includes the Stsadm.exe tool for command-line administration of Windows SharePoint Services servers and sites. Microsoft has added a new operation to repartition a site collection in a content database.

    Windows SharePoint Services 3.0
    KB
    939188
    When you run the "Source to Target" deployment job to deploy custom content on a Windows SharePoint Services 3.0 site, such as a document library, the deployment job is not completed successfully. Instead, you receive an error message that resembles the following error message:
    The file "http://tx1mr1d:91/Documents/test1.doc" is not checked out. You must first check out this document before making changes.
    at Microsoft.SharePoint.Library.SPRequest.AddOrUpdateItem(String bstrUrl, String bstrListName, Boolean bAdd, Boolean bSystemUpdate, Boolean bPreserveItemVersion, Boolean bUpdateNoVersion, Int32& plID, String& pbstrGuid, Guid pbstrNewDocId, Boolean bHasNewDocId, String bstrVersion, Object& pvarAttachmentNames, Object& pvarAttachmentContents, Object& pvarProperties, Boolean bCheckOut, Boolean bCheckin, Boolean bMigration, Boolean bPublish)
    at Microsoft.SharePoint.SPListItem.AddOrUpdateItem(Boolean bAdd, Boolean bSystem, Boolean bPreserveItemVersion, Boolean bNoVersion, Boolean bMigration, Boolean bPublish, Boolean bCheckOut, Boolean bCheckin, Guid newGuidOnAdd, Int32& ulID, Object& objAttachmentNames, Object& objAttachmentContents, Boolean suppressAfterEvents)
    at Microsoft.SharePoint.SPListItem.UpdateInternal(Boolean bSystem, Boolean bPreserveItemVersion, Guid newGuidOnAdd, Boolean bMigration, Boolean bPublish, Boolean bNoVersion, Boolean bCheckOut, Boolean bCheckin, Boolean suppressAfterEvents)
    at Microsoft.SharePoint.SPListItem.Update()
    at Microsoft.SharePoint.Deployment.ImportObjectManager.FixBrokenLookupInListItem(ListItemLookup brokenField)
    at Microsoft.SharePoint.Deployment.ImportObjectManager.FixBrokenLookup(DeploymentLookupField brokenField)
    at Microsoft.SharePoint.Deployment.ImportObjectManager.FixBrokenLookupsForObject(Guid sourceObjectId, Dictionary`2 brokenFieldMap)
    at Microsoft.SharePoint.Deployment.ImportObjectManager.FixBrokenLookupsForListItem(Guid sourceLookupItemId)
    at Microsoft.SharePoint.Deployment.ListItemSerializer.FixBrokenLookups(SPListItem listItem, SerializationInfoHelper infoHelper)
    at Microsoft.SharePoint.Deployment.ListItemSerializer.SetObjectData(Object obj, SerializationInfo info, StreamingContext context, ISurrogateSelector selector)
    at Microsoft.SharePoint.Deployment.XmlFormatter.ParseObject(Type objectType, Boolean isChildObject)
    at Microsoft.SharePoint.Deployment.XmlFormatter.DeserializeObject(Type objectType, Boolean isChildObject, DeploymentObject envelope)
    at Microsoft.SharePoint.Deployment.XmlFormatter.Deserialize(Stream serializationStream)
    at Microsoft.SharePoint.Deployment.ObjectSerializer.Deserialize(Stream serializationStream)
    at Microsoft.SharePoint.Deployment.ImportObjectManager.ProcessObject(XmlReader xmlReader)
    at Microsoft.SharePoint.Deployment.SPImport.DeserializeObjects()
    at Microsoft.SharePoint.Deployment.SPImport.Run()
    date time Content deployment job 'Remote import job for job with sourceID = Source_ID ' failed.The exception thrown was 'Microsoft.SharePoint.SPException' : 'The file "http:// path / filename " is not checked out. You must first check out this document before making changes.'

    Windows SharePoint Services 3.0
    KB
    939535
    Microsoft Windows SharePoint Services 3.0 includes the Stsadm.exe tool for command-line administration of Windows SharePoint Services servers and sites. Microsoft has added a new operation to the Stsadm.exe tool. This operation is called the "renamesite" operation.

    Windows SharePoint Services 3.0
    KB
    939592
    Consider the following scenario. You create a managed property by using the Windows SharePoint Services 3.0 object model. You add the property to a document, and then you upload the document to a document library on a Windows SharePoint Services 3.0 Web site. After a full crawl or an incremental crawl is performed, you try to search for the document that contains the managed property. When the results of the search are returned, the document that contains the managed property is not found.

    Windows SharePoint Services 3.0
    KB
    939592
    In an e-mail message, you click a hyperlink for an assignment in a Microsoft Office SharePoint Server 2007 site. When you do this, you receive the following error message:
    There has been an error while loading the form. Click try again to attempt to load form again. If this error persists, contact the support team for the web site.
    Click close to exit this message.
    The URL URL_path is an unsupported relative URL. Use an absolute URL of prefix with '~sitecollection, for a site-collection-relative URL.

    Windows SharePoint Services 3.0
    KB
    939592
    You make a change to the Manager field in the Active Directory directory service. Then, you perform an incremental update or a full update. When you do this, the Manager field in the Windows SharePoint Services 3.0 site is not updated in the profile of the user. However, if another field, such as the Contact Number field, is also updated, both the Contact Number field and the Manager field are updated in the SharePoint Profile database.

    Windows SharePoint Services 3.0
    KB
    939592
    When you use the Advanced search feature in the document library in a Microsoft Office SharePoint Server 2007 portal site to search for a document that contains a space in the file name, the document is not returned in the Search Results page. However, the document is returned in the search results if you specify the first part of the file name as the keyword for the search.
    For example, a document that is named "Intranet Migration.doc" may not appear in the Advanced search results. If you use "Intranet" or "Migration" as the keyword for the search, the document is returned in the search results.
    This issue occurs because the file name property is stored in the Windows SharePoint Services 3.0 portal library with an encoded "%20." The file name property is not stored with a space.

    Windows SharePoint Services 3.0
    KB
    939809
    This article describes the software update (TZMOVE) that addresses the issue in Microsoft Windows SharePoint Services 3.0 in which items that use the Date and Time fields are off by one hour.
    This issue occurs when one or more of the following conditions are true: • You install a Windows SharePoint Services 3.0 software update that modifies the daylight saving time (DST) period of a time zone definition in the Timezone.xml file.
    • You manually update the DST period of a time zone definition in the Timezone.xml file.

    Windows SharePoint Services 3.0
    KB
    939036
    The Polish language has additional letters, in addition to the standard 26 letters. However, you cannot type some of these additional letters in the Rich Text Editor. For example, this problem occurs when you try to type some Polish letters in a blog or in a custom list that uses the Rich Text Editor.

    Windows SharePoint Services 3.0
    KB
    939878
    You create a subfolder in a document library. When you create a link to a document in the subfolder, you receive an "HTTP 404" error message.

    Windows SharePoint Services 3.0
    KB
    940107
    The Object Model (OM) that contains the function to rename a scalable hosted site was made public for SP1. The function to rename a scalable hosted site is SPSite.Rename(Uri newUri). Originally, this function was internal.

    Windows SharePoint Services 3.0
    KB
    939878
    When you perform an in-place build-to-build upgrade to Windows SharePoint Services 3.0, you may encounter some of the following problems: • The upgrade process fails.
    • The Central Administration site and the Stsadm.exe tool do not work correctly.
    • The Setup program cannot upgrade the configuration database.

    Windows SharePoint Services 3.0
    N/A
    N/A
    A server is running the Turkish version of SharePoint Server 2007. When you try to upload an administrator-approved form template to the server, the upload process fails.

    Windows SharePoint Services 3.0
    N/A
    N/A
    You copy a file or a folder by using the WebDAV Web folder. When you perform an incremental update of a content index, Windows SharePoint Services 3.0 does not index the file or the folder that is copied.

    Windows SharePoint Services 3.0
    N/A
    N/A
    You have many documents that have versions. Some documents have multiple versions. When you import these documents into a document library, you receive the following error message:
    FatalError: Member 'Versions' was not found.
    The problem is likely to occur when you import more than 200 documents.

    Windows SharePoint Services 3.0
    N/A
    N/A
    When you perform an in-place upgrade from Windows SharePoint Services 2.0 to Windows SharePoint Services 3.0, the upgrade fails at random points. Additionally, you receive the following error message:
    An exception of type System.ServiceProcess.TimeoutException was thrown. Additional exception information: Time out has expired and the operation has not been completed.

    Windows SharePoint Services 3.0
    N/A
    N/A
    You have two discussion boards in Windows SharePoint Services 2.0. The name of one discussion board is a part of the name of the other discussion board. When you upgrade to Windows SharePoint Services 3.0, the upgrade fails and you receive the following error message:
    Violation of UNIQUE KEY constraint 'AllUserData_Url'. Cannot insert duplicate key in object 'dbo.AllUserData'

    Windows SharePoint Services 3.0
    N/A
    N/A
    When you upgrade Windows SharePoint Services 2.0 to Windows SharePoint Services 3.0, you may receive the following error message:
    Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
    This problem is likely to occur when the following conditions are true: • You perform a gradual upgrade.
    • The content database is larger than 300 gigabytes (GB).

    Windows SharePoint Services 3.0
    N/A
    N/A
    You set the locale of a site to Turkish. When you try to edit permissions of a document library in this site, you receive the following error message:
    Operation is not valid due to the current state of the object.

    Windows SharePoint Services 3.0
    N/A
    N/A
    You create a site collection in a Windows SharePoint Services 2.0 farm. You associate the site collection with a host header. After you upgrade to Windows SharePoint Services 3.0, you cannot access the sites in this collection.

    Windows SharePoint Services 3.0
    N/A
    N/A
    In Windows SharePoint Services 2.0, you set the application pool identity to Local System. When you perform an in-place upgrade to Windows SharePoint Services 3.0, you receive the following error message in the Configuration Wizard:
    You cannot use Local System or Local Service as the application pool identity for Windows SharePoint Services.

    Windows SharePoint Services 3.0
    N/A
    N/A
    You request an RSS feed. The RSS request contains an ETag field that is older than 15 days. In this situation, you receive the following error message:
    The changeToken refers to a time before the start of the current change log.

    Windows SharePoint Services 3.0
    N/A
    N/A
    You have a list template that has the -Mail Notification option enabled. When you create a list from the list template, you receive the following error message:
    Error: Cannot complete this action
    However, the list is created successfully.

    Windows SharePoint Services 3.0
    N/A
    N/A
    In a document library, you create folders on different levels. You update the permissions of a folder. When you click Manage Permissions for a folder whose level is two or more levels down from the folder in which you have already updated the permissions, you receive the following error message:
    Operation is not valid due to the current state of the object.

    Windows SharePoint Services 3.0
    N/A
    N/A
    You update the server URL of a site collection. For example, you update the server URL of a site collection by migrating the site collection from a server to another server. After you update the server, the alerts in the site collection no longer work.

    Windows SharePoint Services 3.0
    N/A
    N/A
    You apply a hotfix for Windows SharePoint Services 3.0. When you run the PSConfig.exe tool, you receive the following error message:
    System.Data.SqlClient.SqlException: Access to module dbo.proc_MSS_GetConfigurationProperty is blocked because the signature is not valid.

    Windows SharePoint Services 3.0
    N/A
    N/A
    You enable the Document Version History feature of a document library. You update a document in the document library. When you save the document, the version number may not increase.

    Windows SharePoint Services 3.0
    N/A
    N/A
    You have the update permission on a subfolder in a document library. You do not have the update permission on the parent folder. In this situation, you cannot upload documents to the subfolder.

    Windows SharePoint Services 3.0
    N/A
    N/A
    You have a site content type that contains some site columns. The setting of these site columns is Required . When you save a site that uses this content type as a template, the setting of these site columns is not saved. When you create a new site by using the template, the setting of these site columns becomes Optional .

    Windows SharePoint Services 3.0
    N/A
    N/A
    You create a custom ItemDeleting event and set the Cancel property to true . However, in the Explorer view of a document library that uses this custom event, you can successfully perform a drag-and-drop operation on files. You expect that the drag-and-drop operation cannot succeed.

    Windows SharePoint Services 3.0
    N/A
    N/A
    On a multiprocessor computer, several users perform operations on list items at the same time. In this situation, deadlocks may occur.

    Windows SharePoint Services 3.0
    N/A
    N/A
    In a document library, you create a new content type. In the setting of document library, you update the order of the content types in such a way that the new content type comes before the default content type. When you create a new document, the new document uses the template of the original default content type. However, you expect that the new document uses the template of the new content type.

    Windows SharePoint Services 3.0
    N/A
    N/A
    You try to perform an in-place upgrade of Windows SharePoint Services 2.0 to Windows SharePoint Services 3.0. Then, the PSConfig.exe tool displays an error message that states that you must run the pre-upgrade scan tool. However, the error message does not specify the location of the pre-upgrade scan tool.

    Windows SharePoint Services 3.0
    N/A
    N/A
    You create a view of a list to group items by the column of the Date and Time data type. When you open the view, some items may not display in the correct group.

    Windows SharePoint Services 3.0
    N/A
    N/A
    You have an InfoPath form that contains more than 15 fields of the Boolean data type. When you copy this form from a form library to another form library, the copy operation fails.

    Windows SharePoint Services 3.0
    N/A
    N/A
    A server is running the French version of Microsoft Office SharePoint Server 2007. On a SharePoint Web page, when you try to add a KPI Details Web part, you receive the following error message:
    Impossible to add selected component. KPI Details - file is invalid.

    Windows SharePoint Services 3.0
    N/A
    N/A
    You have a site whose time zone is a positive offset to Coordinate Universal Time (UTC). In a calendar list, you click the first day of a month. Then, you switch to the Month view. In the scenario, calendar items whose date is later than the fifth day of the month are not displayed.

    Windows SharePoint Services 3.0
    N/A
    N/A
    You use the Stsadm.exe tool to import a site by using the -includeusersecurity switch. If the site contains a discussion topic whose title ends in the format of a file name extension, you receive the following error message:
    FatalError: This operation can only be performed on a file.
    For example, you receive this error message if the title of the discussion topic is as follows:
    http://www.microsoft.com/hardware/default.aspx

    Windows SharePoint Services 3.0
    N/A
    N/A
    You have a Web application that contains a document library that has lookup columns. When you import or export this Web application, you receive the following error message:
    The file " PageURL " is not checked out. You must first check out this document before making changes.

    Windows SharePoint Services 3.0
    N/A
    N/A
    You have a Web part that contains special characters in the title. For example, a Web part contains the ampersand (&) character. Then, the tooltip for the Web part menu incorrectly displays these special characters.

    Windows SharePoint Services 3.0
    N/A
    N/A
    You have a custom list that contains a lookup column. Additionally, you enable the Allow multiple values option for the column. Additionally, the list contains many security settings. For example, the list contains 1000 item-based security settings. When you open a view of the list that contains the lookup column, the view cannot be displayed.

    Windows SharePoint Services 3.0
    N/A
    N/A
    Windows SharePoint Services 3.0 and SharePoint Server 2007 contain the old time zone setting for New Zealand. The new time zone for New Zealand has an additional three weeks of daylight savings. The additional dayllight savings start from September 30, 2007.

    Windows SharePoint Services 3.0
    N/A
    N/A
    You have a discussion board whose Subject view contains the Reply column. When you click Reply in the Subject view, you receive an "HTTP 400" error.

    Windows SharePoint Services 3.0
    N/A
    N/A
    If you are an anonymous user, you cannot reply to a discussion item in a discussion board.

    Windows SharePoint Services 3.0
    N/A
    N/A
    You have multiple Windows SharePoint Services Web Front End (WFE) servers in a SharePoint Server 2007 farm. You have a back-end server that hosts the Windows SharePoint Services database. You install Windows SharePoint Services Service Pack 1 (SP1) on these WFE servers. However, the Servers in Farm page in the SharePoint Administration site still displays 12.0.0.4518 for the version of the Windows SharePoint Services database. However, you expect that the version is 12.0.0.6219.

    Good luck

    --tolga--

  • Event logging within MOSS and regular asp.net web application

    Event logging in asp.net is pretty straight forward. In MOSS it might be a little different.

    1. Regular asp.net web application

    First, reference the System.Diagnostics namespace.

    using System;

    using System.Collections;

    using System.Configuration;

    using System.Data;

    using System.Linq;

    using System.Web;

    using System.Web.Security;

    using System.Web.UI;

    using System.Web.UI.HtmlControls;

    using System.Web.UI.WebControls;

    using System.Web.UI.WebControls.WebParts;

    using System.Xml.Linq;

    using System.Diagnostics;

     

    public partial class General_EventLogging : System.Web.UI.Page

    {

        protected void Page_Load(object sender, EventArgs e)

        {

            this.WriteToEventLog("my error");      

        }

        private void WriteToEventLog(String _message)

        {      

            String LogFile = "Application";

            String SourceName = "MyCustomApp";

     

            if (!(EventLog.SourceExists(LogFile)))

            {

                EventLog.CreateEventSource(SourceName, LogFile);

            }

     

            EventLog MyLog = new EventLog();

            MyLog.Source = SourceName;

            MyLog.WriteEntry(_message, EventLogEntryType.Error);

     

        }

    }

    2. Custom MOSS 2007 SP1 web part

    In order to get the same piece of code (above) working I advise to use impersonation. Usually, a reader account in MOSS does not have the rights in order to write to a windows log file.

    This routine perform the "writing" of the event to the event log. Just before the event is being written to the log the code will impersonate the current user using the MOSS admin user account.

    Public Sub WriteToEventLog(ByVal _LogFile As String, ByVal _Source As String, ByVal _Input As String)

     

                    Dim oImp As MOSS.Impersonator = Nothing

                    Dim oConst As MOSS.Constants = Nothing

     

                    Dim LogFile As String = String.Empty

                    Dim Source As String = String.Empty

     

                    Source = _Source

                    LogFile = _LogFile

     

                    Try

                        oConst = New MOSS.Constants

                        oImp = New MOSS.Impersonator(oConst.SPSUserName, oConst.SPSDomain, oConst.SPSPwd)

                        oImp.Impersonate()

                        Try

                            If Not EventLog.SourceExists(LogFile) Then

                                EventLog.CreateEventSource(Source, LogFile)

                            End If

     

                            Dim evt As New EventLog

                            evt.Source = Source

                            evt.WriteEntry(_Input, EventLogEntryType.Error)

                        Catch ex As Exception

                        Finally

                            oImp.UndoImpersonation()

                        End Try

                      

                    Catch ex As Exception

                    End Try

    End Sub

    Public Class Impersonator

                Private sUsername As String = String.Empty

                Private sPassword As String = String.Empty

                Private sDomain As String = String.Empty

                Private oImpContext As WindowsImpersonationContext = Nothing

     

                Public Sub New(ByVal _username As String, ByVal _domain As String, ByVal _password As String)

                    sUsername = _username

                    sPassword = _password

                    sDomain = _domain

                End Sub

     

                Private Function Logon() As WindowsIdentity

                    Dim oWinIdentity As WindowsIdentity = Nothing

                    Try

                        Dim handle As IntPtr = New IntPtr(0)

                        Dim bLogOnSuccess As Boolean = False

                        Const LOGON32_LOGON_NETWORK As Integer = 3

                        Const LOGON32_PROVIDER_DEFAULT As Integer = 0

     

                        bLogOnSuccess = LogonUser(sUsername, sDomain, sPassword, LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT, handle)

                        If bLogOnSuccess = False Then

                            Dim errorCode As Integer = Marshal.GetLastWin32Error

                            Throw New Exception("User logon failed. Error number : " & errorCode)

                        End If

                        oWinIdentity = New WindowsIdentity(handle)

                        CloseHandle(handle)

                    Catch ex As Exception

     

                    End Try

     

                    Return oWinIdentity

                End Function

     

                Public Sub Impersonate()

                    Try

                        oImpContext = Logon.Impersonate

                    Catch ex As Exception

     

                    End Try

                End Sub

     

                Public Sub UndoImpersonation()

                    Try

                        oImpContext.Undo()

                    Catch ex As Exception

     

                    End Try

                End Sub

     

                <DllImport("advapi32", SetLastError:=True)> _

              Private Shared Function LogonUser(ByVal lpszUsername As String, _

                       ByVal lpszDomain As String, _

                        ByVal lpszPassword As String, _

                       ByVal dwLogonType As Integer, _

                       ByVal dwLogonProvider As Integer, _

                       ByRef phToken As IntPtr) As Boolean

                End Function

     

                <DllImport("kernel32", CharSet:=CharSet.Auto)> _

              Private Shared Function CloseHandle(ByVal handle As IntPtr) As Boolean

                End Function

     End Class

    Good luck

    --tolga--

  • Welcome

    Hello ASP.NET Community:

    First, I am very excited about my asp.net blog. Thanks Joe and Scott....

    I am an application developer for a global architectual firm. My main responsibilities involve MOSS 2007 and custom web development. We are a full-blown Microsoft shop trying to leverage its latest technoliges. From Silverlight 2.0 over LINQ over MVC to custom web part development for MOSS 2007 SP1. However, recently we are also investing into DotNetNuke...

    Goals

    My goal with this blog is to share my experience and knowledge about the aforementioned technologies. I would like other developers like me to benefit from what I have done and I do.

    Cheers

    --tolga

More Posts