Click here to Skip to main content
15,888,908 members
Home / Discussions / C#
   

C#

 
AnswerRe: Problem while reading data from excel in c# Pin
Wayne Gaylard30-Aug-11 21:29
professionalWayne Gaylard30-Aug-11 21:29 
GeneralRe: Problem while reading data from excel in c# Pin
Mycroft Holmes30-Aug-11 22:38
professionalMycroft Holmes30-Aug-11 22:38 
GeneralRe: Problem while reading data from excel in c# Pin
Wayne Gaylard30-Aug-11 22:56
professionalWayne Gaylard30-Aug-11 22:56 
GeneralRe: Problem while reading data from excel in c# Pin
nainakarri30-Aug-11 23:01
nainakarri30-Aug-11 23:01 
GeneralRe: Problem while reading data from excel in c# Pin
Wayne Gaylard30-Aug-11 23:06
professionalWayne Gaylard30-Aug-11 23:06 
QuestionGet object back from server with .net remoting and Socket connection Pin
MahieuBrecht30-Aug-11 20:03
MahieuBrecht30-Aug-11 20:03 
AnswerRe: Get object back from server with .net remoting and Socket connection Pin
Michael J. Eber8-Sep-11 8:10
Michael J. Eber8-Sep-11 8:10 
Questioncompare two active directory methods Pin
dcof30-Aug-11 11:50
dcof30-Aug-11 11:50 
My goal is to try to use the same logic when verifying groups in the active directory for users if they are on the web or in a windows application. However my current problem is the web application is currently using a config file and having users enter their user name and password. The windows application is having the user click on a desktop shortcut and the application obtains the user infromation from windows authenication.

Is there a way to make code listed in the windows application be more like the web application?
If not,why not?
If so, how would you change the code to make to the windows application?

The windows code is the following:

AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
hread.CurrentPrincipal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
if ((!Thread.CurrentPrincipal.IsInRole("TEST"))
{
MessageBox.Show("Please contact your network administrator if you have any questions",MessageBoxIcon.Error);
return;

}


else

{
Application.Run(new newm());
break;
}


The web code is the following:
using System;
using System.Collections.Generic;
using System.Text;
using System.DirectoryServices;

namespace RtSup
{
public class Validator
{
private string _path;
private string _filterAttribute;

public Validator(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
{
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;
}
_path = result.Path;
_filterAttribute = (String)result.Properties["cn"][0];
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return true;
}

}
}
Questionswitch statement Pin
dcof30-Aug-11 8:31
dcof30-Aug-11 8:31 
AnswerRe: switch statement Pin
PIEBALDconsult30-Aug-11 8:48
mvePIEBALDconsult30-Aug-11 8:48 
AnswerRe: switch statement PinPopular
OriginalGriff30-Aug-11 9:48
mveOriginalGriff30-Aug-11 9:48 
AnswerRe: switch statement Pin
Dylan Morley1-Sep-11 1:25
Dylan Morley1-Sep-11 1:25 
QuestionC# and USB IR camera Pin
sandy630-Aug-11 2:39
sandy630-Aug-11 2:39 
AnswerRe: C# and USB IR camera Pin
BobJanova30-Aug-11 4:48
BobJanova30-Aug-11 4:48 
SuggestionRe: C# and USB IR camera Pin
DaveAuld30-Aug-11 6:34
professionalDaveAuld30-Aug-11 6:34 
QuestionPer Pixel Access in C# winforms Pin
Thomas.D Williams30-Aug-11 2:17
Thomas.D Williams30-Aug-11 2:17 
AnswerRe: Per Pixel Access in C# winforms Pin
lukeer30-Aug-11 4:28
lukeer30-Aug-11 4:28 
GeneralRe: Per Pixel Access in C# winforms Pin
Thomas.D Williams30-Aug-11 5:26
Thomas.D Williams30-Aug-11 5:26 
GeneralRe: Per Pixel Access in C# winforms Pin
BobJanova30-Aug-11 7:04
BobJanova30-Aug-11 7:04 
GeneralRe: Per Pixel Access in C# winforms Pin
Thomas.D Williams30-Aug-11 7:13
Thomas.D Williams30-Aug-11 7:13 
GeneralRe: Per Pixel Access in C# winforms Pin
Pete O'Hanlon30-Aug-11 7:20
mvePete O'Hanlon30-Aug-11 7:20 
GeneralRe: Per Pixel Access in C# winforms Pin
Thomas.D Williams30-Aug-11 11:17
Thomas.D Williams30-Aug-11 11:17 
GeneralRe: Per Pixel Access in C# winforms Pin
BobJanova30-Aug-11 7:38
BobJanova30-Aug-11 7:38 
GeneralRe: Per Pixel Access in C# winforms Pin
Thomas.D Williams30-Aug-11 11:12
Thomas.D Williams30-Aug-11 11:12 
GeneralRe: Per Pixel Access in C# winforms Pin
BobJanova30-Aug-11 23:02
BobJanova30-Aug-11 23:02 

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.