-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: BennyMathew_MVP
Message 2 in Discussion

Hey Vijay,
Here is a WMI code snippet that will give you all the groups the user belongs 
to... maybe you can customize it to your requirement.

make sure you reference System.Management (dll)

using System;
using System.Collections.Generic;
using System.Text;
using System.Management;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string myDomain = "ReplaceWithYourComputerOrDomainName";
            string theUser = "ReplaceWithYourUserName";
            string query = "SELECT * FROM Win32_GroupUser WHERE PartComponent = 
\"Win32_UserAccount.Domain='" + myDomain + "',Name='" + theUser + "'\"";
            SelectQuery selectQuery = new SelectQuery(query);
            ManagementObjectSearcher searcher = new
            ManagementObjectSearcher(selectQuery);

            foreach (ManagementObject obj in searcher.Get())
            {
                Console.WriteLine(obj.GetPropertyValue("GroupComponent"));
            }
            Console.ReadLine();

        }
    }
}

Regards
Benny Mathew
Seamless Integration Solutions
BizTalk Consulting, Development, Training
Bangalore, India
Cell: +91-9945602604 / Office: +91-80-41676177
http://www.seamless.in
http://GeeksWithBlogs.net/benny


-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member 
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you 
received this message by mistake, please click the "Remove" link below. On the 
pre-addressed e-mail message that opens, simply click "Send". Your e-mail 
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to