Solved

created an empty class and need to call it form a form1 which is in th the same windows application.

Posted on 2008-06-24
3
221 Views
Last Modified: 2013-12-16
using System;
using System.Collections.Generic;
using System.Text;

namespace InitialPrices
{
    class AuthenticateActiveDirectory
    {
        public bool UserExistInActiveDirectory ()
        {
        string sPath = "LDAP://peach/dc=wpg,dc=cwb,dc=ca";
        string fullname = System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();
        string[] parts = fullname.Split('\\');
        string sDomain = parts[0];
        string sUser = parts[1];
        string sGroup = "gl ca corporate data";
           
        InitialPrices.InitialPriceReportingServiceWS.InitialPriceReportingService WS =
            new InitialPrices.InitialPriceReportingServiceWS.InitialPriceReportingService();
        if ((sUser == "gtgifford") || (sUser == "mxcupryk") || (sUser == "ggervais"))
        {
            return (true);
        }
        else
        {
                return( WS.CheckUserAgainstGroupMembers(sPath, sDomain, sGroup, sUser));

        }
        }
    }
}

Need to fix the above so I can call it from my form1.cs
0
Comment
Question by:mathieu_cupryk
  • 2
3 Comments
 
LVL 16

Accepted Solution

by:
burakiewicz earned 500 total points
ID: 21855759
if you use this you should be able to call it on the form
AuthenticateActiveDirectory aad = new AuthenticateActiveDirectory();
aad.UserExistInActiveDirectory ();

if you change to this
public bool UserExistInActiveDirectory ()  to
public static bool UserExistInActiveDirectory ()

then you can call by
AuthenticateActiveDirectory.UserExistInActiveDirectory ();
0
 

Author Comment

by:mathieu_cupryk
ID: 21856000

i should create a constructor and also public class?

namespace InitialPrices
{
      class AuthenticateActiveDirectory
      {
            public static bool UserExistInActiveDirectory ()
            {
            string sPath = "LDAP://peach/dc=wpg,dc=cwb,dc=ca";
            string fullname = System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();
            string[] parts = fullname.Split('\\');
            string sDomain = parts[0];
            string sUser = parts[1];
            string sGroup = "gl ca corporate data";
               
            InitialPrices.InitialPriceReportingServiceWS.InitialPriceReportingService WS =
                  new InitialPrices.InitialPriceReportingServiceWS.InitialPriceReportingService();
            if ((sUser == "gtgifford") || (sUser == "mxcupryk") || (sUser == "ggervais"))
            {
                  return (true);
            }
            else
            {
                        return( WS.CheckUserAgainstGroupMembers(sPath, sDomain, sGroup, sUser));

            }
            }
      }
}
0
 
LVL 16

Expert Comment

by:burakiewicz
ID: 21856133
if you have it as static like in your code, you should be able to call it from the form, if not make the class public..
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question