Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
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
Medium Priority
?
229 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 16

Accepted Solution

by:
burakiewicz earned 2000 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

610 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