?
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
?
226 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

How to Create Failover DNS Record Sets in Route 53

Route 53 has the ability to easily configure DNS record sets specifically for failover scenarios. These failover record sets can be configured to failover to full-blown deployments in other regions or to a static HTML page that informs your customers of the issue.

Question has a verified solution.

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

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!
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

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