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
219 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
Comment Utility
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
Comment Utility

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
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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:…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This video discusses moving either the default database or any database to a new volume.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

762 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now