Tuesday, July 15, 2014

Check if a user exists in Windows Domain - .NET

Well, this code snippet checks a the existence of a list of users and returns false if at least one is invalid.

Input format: mydomain\user;hellodomain\myname;myname;HELLO\World

private bool CheckUserExists(string users)
{
    string DefaultDomain = "MYDEFAULTDOMAIN";
    bool ret = false;

    string[] Users = users.Split(new char[]{ ';'});
    for (int i = 0; i < Users.Length; i++)
    {
        try
        {
            string DomUser = Users[i].Replace('\\', '/');
            if (DomUser.IndexOf('/') == -1)
            {
                DomUser = DefaultDomain + "/" + DomUser;
            }
            DirectoryEntry.Exists(
                 String.Format("WinNT://{0}, user", DomUser));
            ret = true;
        }
        catch (Exception)
        {
            ret = false;
        }
        if (!ret) break;  
            // exit loop if an invalid username is found
    }
            
    return ret;
}

Monday, July 14, 2014

Saturday, July 5, 2014

Thursday, July 3, 2014

Next K-MUG UG on 26 July 2014

One more K-MUG user group event on the way. Howz this banner made for facebook :)

kmugbanner

Thursday, June 26, 2014

Send mail using Exchange Server / EWS 2.0 API

using Microsoft.Exchange.WebServices.Data;

            ExchangeService service = new ExchangeService();
            service.Credentials = new WebCredentials("email@yourexchange.com", "your pass");
            service.AutodiscoverUrl("email@yourexchange.com", delegate(string url) { return (new Uri(url).Scheme == "https"); });
            EmailMessage email = new EmailMessage(service);
            email.ToRecipients.Add("email@anothermail.com");
            email.Subject = "test";
            email.Body = new MessageBody("test");
            email.Send();


This should work in most cases, unless you have a more advanced configuration.

Download EWS 2.0 API  from - http://www.microsoft.com/en-in/download/details.aspx?id=35371
Reference URL: http://msdn.microsoft.com/en-us/library/office/jj220499(v=exchg.80).aspx

Tuesday, June 24, 2014

Deep Learning


"Deep learning is a set of algorithms in machine learning that attempt to model high-level abstractions in data by using architectures composed of multiple non-linear transformations."

Source: Wiki

Here is a good reading on the same from Analytics Vidya, which now a days is one of my favorite site which deals with Big Data and Analysis.
Another related url here.

Monday, June 23, 2014

Open compose mail dialog from .NET

I do not consider this as a straight forward method, but will work in most cases, provided the machine you run is having a "default" mail application. Eg: Outlook.

System.Diagnostics.Process.Start
("mailto:test@test.com;blah@blee.com;hello@hello.com");