Posts

Showing posts from April, 2013

Validate domain user using c#

Hi, Here am sharing code related to validate a domain user againsta active directory. This is well used for implementing authentication and authorization in asp.net or windows application. the call should be sent a [domainname]\[username] and [password] public int VerifyUser(string userName, string password) { try { string domainName = string.Empty; string domainUserName = string.Empty; string[] tempString = null; string[] delimiter = new string[] { @"\" }; tempString = userName.Split(delimiter, StringSplitOptions.RemoveEmptyEntries); if ((tempString.Length == 0) || (tempString.Length == 1)) { return 1; } domainName = tempString[0]; domainUserName = tempString[1]; LDAP.Domain_Authentication imperson = new LDAP.Domain_Authentication(domainUserName, password, domainName); if (imperson.IsValid()) { return 2; } return 3; } catch (Exception ex) { return -1; } } And the LDAP class i

server side printing / PDF conversions using c# and asp.net/wcf service

Hi All, I know its a tough task to search this kind of  requirement . As i did same and endup with a solution like using Crystal reports for printing on network printer. And a WKHTML library to convert html pages to either images or PDF. There inturn i can convert TIFF files to PDF using Ghostscript(If you need this code please drop a comment). Now coming to this server side network printing. At first we need to have a following things Visual studio Crystal reports for Visual studio WKHTMLTOPDF/WKHTMLTOIMAGE A proper permissions on a folder where we are going to store our images or PDF files etc which need to be sent to a printer And the code flow is first i will scale the image to a standard size with the following code  prepare a HTML file having image tag with SRC as the image file which needs to be printed then i will call WKHTMLTOIMAGE library  to convert public static Image ScaleImage(Image image, int maxWidth, int maxHeight) { var ratioX