Click here to Skip to main content
15,891,423 members
Home / Discussions / C#
   

C#

 
AnswerRe: Lock DLL in C# Pin
Abhinav S2-Sep-11 21:25
Abhinav S2-Sep-11 21:25 
AnswerRe: Lock DLL in C# Pin
harold aptroot3-Sep-11 1:32
harold aptroot3-Sep-11 1:32 
AnswerRe: Lock DLL in C# PinPopular
jschell3-Sep-11 10:43
jschell3-Sep-11 10:43 
GeneralRe: Lock DLL in C# Pin
Eddy Vluggen3-Sep-11 13:04
professionalEddy Vluggen3-Sep-11 13:04 
QuestionEmailSender : A socket operation was attempted to an unreachable network Pin
bigz_10002-Sep-11 19:53
bigz_10002-Sep-11 19:53 
AnswerRe: EmailSender : A socket operation was attempted to an unreachable network Pin
Mehdi Gholam2-Sep-11 20:03
Mehdi Gholam2-Sep-11 20:03 
Question[SOLVED] "Negative" Rectangle (ControlPaint.DrawReversibleFrame) To "Positive" Pin
Matt U.2-Sep-11 13:39
Matt U.2-Sep-11 13:39 
QuestionC# code for windows Pin
dcof2-Sep-11 6:45
dcof2-Sep-11 6:45 
i am trying to make the following web code work for a C#.net 2008 desktop application. My company wants us to use the same logic to check groups in the active directory. The following is the code snippet I obtained from the contract. 

From the contractor, i also obtained the xml file. The three columns i am referring to are not in the xml file. The fields I am trying to figure out how they are referenced in the app code are the following: 

DirectoryEntry
DirectorySearcher
SearchResult.

Would you have any idea what I can use to point to the columns listed above are that I can use in a C#.net 2008 desktop application? if so, can you show me some code and/or point to a url that I can use as a reference?

The following is the code i am trying to work with:i am trying to make the following web code work for a C#.net 2008 desktop application. My company wants us to use the same logic to check groups in the active directory. The following is the code snippet I obtained from the contract. 

From the contractor, i also obtained the xml file. The three columns i am referring to are not in the xml file. The fields I am trying to figure out how they are referenced in the app code are the following: 

DirectoryEntry
DirectorySearcher
SearchResult.

Would you have any idea what I can use to point to the columns listed above are that I can use in a C#.net 2008 desktop application? if so, can you show me some code and/or point to a url that I can use as a reference?

The following is the code i am trying to work with:


using System;
using System.Collections.Generic;
using System.Text;
using System.DirectoryServices;

namespace Sup
{
    public class ActiveDirectoryValidator
    {
        private string _path;
        private string _filterAttribute;

        public ActiveDirectoryValidator(string path)
        {
            _path = path;
        }

        public bool IsAuthenticated(string domainName, string userName, string password)
        {
         string domainAndUsername = domainName + @"\" + userName;
         DirectoryEntry entry = new DirectoryEntry(_path, domainAndUsername, password);
            try
            {
         // Bind to the native AdsObject to force authentication.
          Object obj = entry.NativeObject;
          DirectorySearcher search = new DirectorySearcher(entry);
          search.Filter = "(SAMAccountName=" + userName + ")";
          search.PropertiesToLoad.Add("cn");
          SearchResult result = search.FindOne();
          if (null == result)
             {
                return false;
             }
          // Update the new path to the user in the directory
           _path = result.Path;
            _filterAttribute = (String)result.Properties["cn"][0];
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return true;
        }

    }
}

AnswerRe: C# code for windows Pin
Abhinav S2-Sep-11 6:59
Abhinav S2-Sep-11 6:59 
QuestionRe: C# code for windows Pin
dcof2-Sep-11 18:13
dcof2-Sep-11 18:13 
AnswerMessage Removed Pin
2-Sep-11 7:05
professionalN_tro_P2-Sep-11 7:05 
GeneralRe: C# code for windows Pin
Luc Pattyn2-Sep-11 7:15
sitebuilderLuc Pattyn2-Sep-11 7:15 
GeneralRe: C# code for windows Pin
Abhinav S2-Sep-11 8:01
Abhinav S2-Sep-11 8:01 
QuestionRe: C# code for windows Pin
dcof2-Sep-11 8:34
dcof2-Sep-11 8:34 
AnswerRe: C# code for windows Pin
Abhinav S2-Sep-11 18:33
Abhinav S2-Sep-11 18:33 
GeneralRe: C# code for windows Pin
dcof2-Sep-11 8:19
dcof2-Sep-11 8:19 
GeneralRe: C# code for windows Pin
Richard Andrew x642-Sep-11 8:46
professionalRichard Andrew x642-Sep-11 8:46 
GeneralRe: C# code for windows Pin
dcof2-Sep-11 8:51
dcof2-Sep-11 8:51 
AnswerRe: C# code for windows Pin
OriginalGriff2-Sep-11 8:48
mveOriginalGriff2-Sep-11 8:48 
GeneralRe: C# code for windows Pin
dcof2-Sep-11 8:53
dcof2-Sep-11 8:53 
GeneralMessage Removed Pin
2-Sep-11 9:28
professionalN_tro_P2-Sep-11 9:28 
GeneralRe: C# code for windows Pin
dcof2-Sep-11 18:08
dcof2-Sep-11 18:08 
GeneralRe: C# code for windows Pin
Luc Pattyn2-Sep-11 14:09
sitebuilderLuc Pattyn2-Sep-11 14:09 
GeneralRe: C# code for windows Pin
dcof5-Sep-11 16:45
dcof5-Sep-11 16:45 
QuestionFacebook friends birthdays? Pin
assafey2-Sep-11 4:34
assafey2-Sep-11 4:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.