lamp
Underscore prefix with C#, is it a best practice?
01 March 10 01:52 PM | Frederick.Chapleau | with no comments

I used this since the beginning, thinking that this was a best practice, but without searching a lot.

I found this article containing a brief history on this practice... I’ll let you decide if it’s a best practice to you.

http://blogs.msdn.com/sourceanalysis/archive/2008/05/25/a-difference-of-style.aspx

-f.

Filed under:
Atlasian: Really, really great, and almost FREE!
19 February 10 11:04 AM | Frederick.Chapleau | with no comments

10$ for Each of :

JIRA : The best Issue Tracker

Confluence : The best Wiki/Blog engine

… and many others!

http://www.atlassian.com/starter/

-f.

Filed under:
Get the Unread count of the Inbox of Exchange 2010/2007, using web services
02 February 10 09:28 AM | Frederick.Chapleau | with no comments

I searched a lot and, based on an article from SANDEEP APARAJIT, I was able to query for unread email from my Exchange mailbox inbox, in about 15 min. Thanks!

 

ServicePointManager.ServerCertificateValidationCallback = delegate(Object obj, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors) { return true; };

ExchangeServiceBinding service = new ExchangeServiceBinding ();

service.RequestServerVersionValue = new RequestServerVersion();
service.RequestServerVersionValue.Version = ExchangeVersionType.Exchange2010;
service.EnableDecompression = true;
service.Credentials = new NetworkCredential("username", "password", "domain");
service.Url = @https://exchangeserver/EWS/exchange.asmx;

int merCurrentCount = GetUnreadFolderItemsCount(service, "Inbox");

… and the functions…

public int GetUnreadFolderItemsCount(ExchangeServiceBinding service, string folderName)
       {
           int unReadCount = -1;
           // Identify the folder properties to return.
           FolderResponseShapeType properties = new FolderResponseShapeType();
           PathToUnindexedFieldType ptuft = new PathToUnindexedFieldType();
           ptuft.FieldURI = UnindexedFieldURIType.folderManagedFolderInformation;
           PathToUnindexedFieldType[] ptufts = new PathToUnindexedFieldType[1] { ptuft };
           properties.AdditionalProperties = ptufts;
           properties.BaseShape = DefaultShapeNamesType.AllProperties;

           // Form the get folder request.
           BaseFolderIdType p_folder = FindFolderID(service, folderName);

           GetFolderType request = new GetFolderType();
           request.FolderIds = new BaseFolderIdType[1] { p_folder };
           request.FolderShape = properties;

           // Send the request and get the response.
           GetFolderResponseType response = service.GetFolder(request);

           ArrayOfResponseMessagesType aormt = response.ResponseMessages;
           ResponseMessageType[] rmta = aormt.Items;
           foreach (ResponseMessageType rmt in rmta)
           {
               if (rmt.ResponseClass == ResponseClassType.Error)
               {
                   throw new Exception(rmt.MessageText);
               }
               else
               {
                   FolderInfoResponseMessageType firmt;
                   firmt = (rmt as FolderInfoResponseMessageType);
                   BaseFolderType[] folders = firmt.Folders;

                   foreach (BaseFolderType rfolder in folders)
                   {
                       if (rfolder is FolderType)
                       {
                           FolderType myFolder;
                           myFolder = (rfolder as FolderType);
                           if (myFolder.UnreadCountSpecified)
                           {
                               unReadCount = myFolder.UnreadCount;
                           }
                       }
                   }
               }
           }
           return unReadCount;
       }

       public static FolderIdType FindFolderID(ExchangeServiceBinding service, String folderName)
       {
           DistinguishedFolderIdType objSearchRootFolder = new DistinguishedFolderIdType();
           objSearchRootFolder.Id = DistinguishedFolderIdNameType.msgfolderroot;

           FindFolderType requestFindFolder = new FindFolderType();
           requestFindFolder.Traversal = FolderQueryTraversalType.Deep;
           requestFindFolder.ParentFolderIds = new DistinguishedFolderIdType[] { objSearchRootFolder };
           requestFindFolder.FolderShape = new FolderResponseShapeType();
           requestFindFolder.FolderShape.BaseShape = DefaultShapeNamesType.IdOnly;

           //Search filter definition
           requestFindFolder.Restriction = new RestrictionType();

           #region Contains expression

           ContainsExpressionType objContainsExpression = new ContainsExpressionType();
           objContainsExpression.ContainmentMode = ContainmentModeType.FullString;
           objContainsExpression.ContainmentModeSpecified = true;
           objContainsExpression.ContainmentComparison = ContainmentComparisonType.Exact;
           objContainsExpression.ContainmentComparisonSpecified = true;

           PathToUnindexedFieldType objFieldFolderName = new PathToUnindexedFieldType();
           objFieldFolderName.FieldURI = UnindexedFieldURIType.folderDisplayName;
           objContainsExpression.Item = objFieldFolderName;

           objContainsExpression.Constant = new ConstantValueType();
           objContainsExpression.Constant.Value = folderName;

           #endregion Contains expression

           requestFindFolder.Restriction.Item = objContainsExpression;

           FindFolderResponseType objFindFolderResponse =
               service.FindFolder(requestFindFolder);

           if (objFindFolderResponse.ResponseMessages.Items.Length == 0)
               return null;

           foreach (ResponseMessageType responseMsg in
               objFindFolderResponse.ResponseMessages.Items)
           {
               if (responseMsg.ResponseClass == ResponseClassType.Success)
               {
                   FindFolderResponseMessageType objFindResponse =
                       responseMsg as FindFolderResponseMessageType;
                   foreach (
                       BaseFolderType objFolderType in objFindResponse.RootFolder.Folders)
                   {
                       return objFolderType.FolderId;
                   }
               }
           }
           return null;
       }

-f.

Filed under:
SSL for FREE
15 January 10 09:45 AM | Frederick.Chapleau | with no comments

Yes, we can now secure servers using free certificates :)

http://StartSSL.com

-f.

Filed under:
The registry on a 64bits OS using NSIS
13 January 10 08:10 PM | Frederick.Chapleau | with no comments

Ok, after trying to find a patch or a work around to access the write 64 bit registry node instead of the Wow6432Node, I found a … not very documented but simple way to do it...

${If} ${RunningX64}
     SetRegView 64
${EndIf}

-f.

Filed under:
FH_DATE_PAST_20XX in SpamAssassin not working in 2010
02 January 10 12:26 PM | Frederick.Chapleau | with no comments

Yep, it was a bug, but it’s corrected now, 3 Steps to follow:

1. Change the mirrors

Edit the file /var/lib/spamassassin/3.002003/updates_spamassassin_org/MIRRORED_BY and add

http://daryl.dostech.ca/sa-update/asf/ weight=5
http://www.sa-update.pccc.com/ weight=5

2. Run sa-update

3. Run sa-Compile

… or you can simply patch it by editing the file /etc/mail/spamassassin/local.cf and add

score FH_DATE_PAST_20XX 0

And you are done :)

-f.

Filed under:
gPXE chaining / DHCP / TFTP / TGT / iSCSI to boot Windows 7 Diskless!
14 November 09 02:58 PM | Frederick.Chapleau | 1 comment(s)

By default the LUN number is 0, when you insert in the dhcp server

iscsi:ServerAddress.x.com::::iqn.2009-11.com.x:test

The problem is that TGT is by default assigning 0 to the controller of the iSCSI drive, and the LUN number for the device itself is 1.

So you must assign the value 1 to the definition.

iscsi:ServerAddress.x.com:::1:iqn.2009-11.com.x:test

… if you don’t assign it, you will get error “ 0x1d704039 ", or PXENV_STATUS_TFTP_CANNOT_READ_FROM_CONNECTION.

 

-f.

BTW, here is my configs…

dhcpd.conf

#
# DHCP Server Configuration file.
#   see /usr/share/doc/dhcp*/dhcpd.conf.sample
#
allow booting;
allow bootp;

option space gpxe;
option gpxe.bus-id code 177 = string;
option gpxe-encap-opts code 175 = encapsulate gpxe;
option gpxe.keep-san code 8 = unsigned integer 8;

subnet 10.0.0.0 netmask 255.255.255.0 {
        range 10.0.0.200 10.0.0.220;
        authoritative;
        next-server 10.0.0.1;
        if not exists gpxe.bus-id {
                filename "gpxe.kpxe";
        } else {
                filename "";
                option root-path "iscsi:10.0.0.1:::1:iqn.2009-11.com.x:test";
                option gpxe.keep-san 1;
        }
}
ddns-update-style ad-hoc;
option time-servers 10.0.0.10;
option domain-name "x.com";
option routers 10.0.0.1;
option ntp-servers 10.0.0.1;
option domain-name-servers 10.0.0.1;
option subnet-mask 255.255.255.0;

targets.conf

<target iqn.2009-11.com.x:test>
        backing-store /san/disk1
</target>

Filed under:
Configure FileStream in SQL Server 2008
26 October 09 12:39 PM | Frederick.Chapleau | with no comments

It’s not only a setting in the insance properties, you must also configure it using the SQL Server Configuration Manager.

I had this problem when importing the AdventureWorksCycle 2008 database, and I found this article really helpfull.

ref.: http://techpunch.wordpress.com/2008/08/29/how-to-enable-filestream-feature-on-sql-server-2008/

-f.

Filed under:
Using WCF Webservices in .NET 2.0
14 September 09 01:00 PM | Frederick.Chapleau | with no comments

The default behavior of WCF Webservice is the new wsHttpBinding. This is not compatible with .NET 2.0, so to use it you must change the behavior with the basicHttpBinding.

The basic one is not secured, so if it’s a critical piece, you must use it with SSL.

-f.

ref.: http://www.slickit.ca/2009/04/wcf-using-wcf-with-net-20.html

Filed under:
This collection already contains an address with scheme http.
12 September 09 12:02 PM | Frederick.Chapleau | with no comments

When deploying a WCF service, this problem can occur

This collection already contains an address with scheme http.  There can be at most one address per scheme in this collection.
Parameter name: item

This is caused by having multiple binding on the Website (like domain.com and www.domain.com).

The solution was simply to add a entry in the serviceHostingEnvironment section of the web.config, check out the reference for the complete solution.

warning: this cause the server to reject everything that is not configured in the baseAddressPrefixFilters.

-f.

ref.: http://blogs.msdn.com/rampo/archive/2008/02/11/how-can-wcf-support-multiple-iis-binding-specified-per-site.aspx

Filed under:
404 Error when deploying a .net 3.0+ SVC File
12 September 09 11:49 AM | Frederick.Chapleau | with no comments

When deploying a .NET WCF Service on IIS 7, on might have a 404 error.

This is because the ScriptsMaps are not registered, issuing the following command register them, to that they can be used.

c:\Windows\Microsoft.Net\Framework\v3.0\Windows Communication Foundation\servicemodelreg.exe –i

-f.

ref.: http://forums.asp.net/t/1432444.aspx

Filed under:
Change SQL Server Instance Name
20 July 09 10:14 AM | Frederick.Chapleau | with no comments

After looking around a lot, I found this article that is really accurate, when you changed the server name, and not the SQL Server Instance name...

http://www.coderjournal.com/2008/02/how-to-change-instance-name-of-sql-server/

-f.

Filed under:
The log cannot be rebuilt when the primary file is read-only.
08 July 09 06:27 PM | Frederick.Chapleau | 1 comment(s)

When mounting a SQL Server Express Database, the SQL Server Express engine is trying to rebuild the log files, using the same permissions as the AppPool that is configured for the website. So this account should have access to the underneath file system. Try giving Network Service Account read/write permissions on the App_Data folder...

-f.

Filed under:
cannot generate sspi context. .net sqlclient data provider
08 July 09 01:38 PM | Frederick.Chapleau | with no comments

I had this, and found a lot of posts for it... here is an other “simple” solution: change de provider name to Named Pipe, it this case the SSPI context is generating correctly.

-f.

Filed under:
DNS Error when activating Windows 2008
07 July 09 01:00 PM | Frederick.Chapleau | 1 comment(s)

If you receive this error when activating Windows 2008, change the product key to use a MAK product key (I think it’s a volumen license key) and not a MSDN product key (RTL).

Windows Activation Error
A problem occurred when Windows tried to activate. Error Code 0x8007232B.
For a possible resolution, click More Information.
Contact your system administratior or technical support department for
assistance.
More Information says -> Code: 0x8007232B, Description: DNS name does not
exists.

-f.

Filed under:
More Posts Next page »