Archive for Novembre 28th, 2007

Blogging: The Free Internet Marketing Method

WebReference News Novembre 28th, 2007

Blogging is one of the easiest ways to get your message noticed on the Web. While blogging has now become a hot method for teens to broadcast their thoughts, it’s also a great Internet marketing tool. By Rodney T. 1010

Validate A User’s Active Directory Credentials (pre-Windows XP)

CodeKeep C# Feed Novembre 28th, 2007

Description: How to validate a user's credentials in Windows 2000. For XP, use the code snippet "Validate A User's Active Directory Credentials".

Link: http://www.codekeep.net/snippets/2541ce83-624a-4f57-869a-f3475cd23384.aspx

        /// <summary>
        /// Validate a user's credentials against active directory.
        /// 
        /// Only use this method for PRE-XP operating systems.
        /// </summary>
        /// <param name="DomainName">string.  The user's domain name.  Example "AMERICAS"</param>
        /// <param name="UserName">string.  User name. Example "kevin_shuma"</param>
        /// <param name="Password">string.  The user's password.</param>
        /// <returns>bool.  True = authentication success, False = authentication failure.</returns>
        public static ValidateUserCredentialsReturnCodes
            ValidateUserCredentialsPreXP(string DomainName, string UserName, string Password)
        {
            try
            {
                DirectoryEntry User = new DirectoryEntry("LDAP://" + DomainName, UserName, Password, AuthenticationTypes.Secure);

                // the following assignment will raise an error if the login information is incorrect
                try
                {
                    UserName = User.Name;
                }
                catch (Exception AuthEx)
                {
                    // make sure we got an authentication error
                    if (AuthEx.Message.IndexOf("Logon failure") == -1) // not an authentication error
                        throw AuthEx; // rethrow the error to the general exception handler
                    else
                    {
                        // return an error indicating bad user name or password
                        return ValidateUserCredentialsReturnCodes.ERROR_BAD_USERNAME_OR_PASSWORD;
                    }
                }

                // everything passed okay, authentication was successful
                return ValidateUserCredentialsReturnCodes.SUCCESS;
            }
            catch (Exception ex)
            {
                //Logging.LogException(MethodBase.GetCurrentMethod(), ref ex);
                return ValidateUserCredentialsReturnCodes.UNKNOWN_ERROR;
            }
        }

Inside Camtasia Studio 5: Part 1

WebReference News Novembre 28th, 2007

In this article we’re going to look at the major new features of Camtasia Studio 5, including: the streamlined recorder, SmartFocus, ExpressShow, new editing features, features for bloggers, FTP and Screencast, transitions and the project settings. By Nathan Segal. 1024

How to Promote Your Product with Organic Search

WebReference News Novembre 28th, 2007

Pay-per-click marketing is often quite expensive and is one of the major complaints of small businesses. An alternative? Work at improving your organic search results. By Michael Fleischner. 1119.

DataTable - Creating and Using - Labels

CodeKeep C# Feed Novembre 28th, 2007

Description: DataTable - Creating and Using

Link: http://www.codekeep.net/snippets/1e0325ea-0b31-4db3-a9f8-1f9ff1dc4061.aspx

string Name = @"C:\Documents and Settings\kaa8823\My Documents\Visual Studio 2005\Projects\Classes\Solution\LabelPrinter\LabelMaker1\bin\Debug\Database\Data.dat";
            string ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Name;

            string sSQL = "SELECT ITEMNUM, LOCATION, CATALOGCODE, ISSUEUNIT, DESCRIPTION from MATERIAL ORDER BY ITEMNUM";
            OleDbDataReader dr;
            OleDbConnection oCnn = new OleDbConnection(ConnectionString);
            OleDbCommand oCmd = oCnn.CreateCommand();

            DataTable mTable = new DataTable();
            DataRow mLine;
            mTable.Columns.Add(new DataColumn("ITEMNUM", typeof(string)));
            mTable.Columns.Add(new DataColumn("LOCATION", typeof(string)));
            mTable.Columns.Add(new DataColumn("CATALOGCODE", typeof(string)));
            mTable.Columns.Add(new DataColumn("ISSUEUNIT", typeof(string)));
            mTable.Columns.Add(new DataColumn("DESCRIPTION", typeof(string)));

            oCnn.Open();
            oCmd.CommandText = sSQL;
            dr = oCmd.ExecuteReader();
            while (dr.Read())
            {
                mLine = mTable.NewRow();
                mLine["ITEMNUM"] = dr["ITEMNUM"].ToString();
                mLine["LOCATION"] = dr["LOCATION"].ToString();
                mLine["CATALOGCODE"] = dr["CATALOGCODE"].ToString();
                mLine["ISSUEUNIT"] = dr["ISSUEUNIT"].ToString();
                mLine["DESCRIPTION"] = dr["DESCRIPTION"].ToString();
                
                mTable.Rows.Add(mLine);
            }
            dr.Close();
            oCnn.Close();

            this.dataGridView1.DataSource = mTable;

SPSolutions.ServiceModel.ServiceUtil

CodeKeep C# Feed Novembre 28th, 2007

Description: WCF client utility class for calling web services.

Link: http://www.codekeep.net/snippets/bad7d94e-29da-415a-b69b-ceb75d3b753d.aspx

using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.Xml.Xsl;
using System.Xml;

namespace SPSolutions.ServiceModel
{
    internal static class ServiceUtil
    {
        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="action"></param>
        internal static void UseServiceClient<T>(Action<T> action)
        {
            UseServiceClient<T>(action, null, null, null);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="action"></param>
        /// <param name="domain"></param>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        internal static void UseServiceClient<T>(Action<T> action, string domain, string userName, string password)
        {
            ChannelFactory<T> factory = new ChannelFactory<T>("*");

            // Otherwise use default credentials
            if (!(string.IsNullOrEmpty(domain) && string.IsNullOrEmpty(userName) && string.IsNullOrEmpty(password)))
            {
                factory.Credentials.Windows.ClientCredential.Domain = domain;
                factory.Credentials.Windows.ClientCredential.UserName = userName;
                factory.Credentials.Windows.ClientCredential.Password = password;
            }

            T client = factory.CreateChannel();

            try
            {
                action(client);
                ((IClientChannel)client).Close();
                factory.Close();
            }
            catch
            {
                ((IClientChannel)client).Abort();
                factory.Abort();
                throw;
            }
        }
    }
}