Click here to Skip to main content
16,005,389 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
AnswerRe: Object reference not set to an instance of an object. Pin
Pete O'Hanlon26-Jul-09 9:09
mvePete O'Hanlon26-Jul-09 9:09 
GeneralRe: Object reference not set to an instance of an object. Pin
ChiSmile26-Jul-09 9:16
ChiSmile26-Jul-09 9:16 
GeneralRe: Object reference not set to an instance of an object. Pin
Pete O'Hanlon26-Jul-09 10:13
mvePete O'Hanlon26-Jul-09 10:13 
QuestionAutoGenerateColumns being overwritten by Visual Studio IDE Pin
Kevin Geary25-Jul-09 9:54
Kevin Geary25-Jul-09 9:54 
AnswerRe: AutoGenerateColumns being overwritten by Visual Studio IDE Pin
Henry Minute26-Jul-09 9:51
Henry Minute26-Jul-09 9:51 
QuestionWhy does Crystal take so long to set datasource only the first time Pin
Hypermommy25-Jul-09 2:30
Hypermommy25-Jul-09 2:30 
QuestionActiveElement Pin
majidmadadi24-Jul-09 19:14
majidmadadi24-Jul-09 19:14 
QuestionActiveDirectory Question [SOLVED] Pin
#realJSOP24-Jul-09 2:48
professional#realJSOP24-Jul-09 2:48 
(using .net 3.5)

I'm trying to get a list of groups that a given user is a member of. I'm trying to use the following code (using the System.DirectoryServices.AccountManagement namespace):

PrincipalContext context = new PrincipalContext(ContextType.Domain, "myDomain");

UserPrincipal userPrincipal = UserPrincipal.FindByIdentity(context, IdentityType.SamAccountName, this.UserID);

PrincipalSearchResult<Principal> groups = userPrincipal.GetGroups(context);


It's throwing an exception on the 2nd line of code, saying that the userID or password is invalid.

I know for a fact that the userID I'm using exists on the domain. What am I doing wrong?

EDIT (SOLUTION) =====================

I had to change the first line to this:

PrincipalContext context = new PrincipalContext(ContextType.Domain, "myDomain", userID, password);



"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001


Questiondetailsview edit Pin
rim jhim23-Jul-09 20:44
rim jhim23-Jul-09 20:44 
AnswerRe: detailsview edit Pin
Suvabrata Roy19-Mar-13 23:54
professionalSuvabrata Roy19-Mar-13 23:54 
QuestionHow would one go about doing this? (Code Coverage) Pin
gantww23-Jul-09 15:15
gantww23-Jul-09 15:15 
AnswerRe: How would one go about doing this? (Code Coverage) Pin
Jimmanuel23-Jul-09 17:43
Jimmanuel23-Jul-09 17:43 
AnswerRe: How would one go about doing this? (Code Coverage) Pin
Curtis Schlak.23-Jul-09 18:10
Curtis Schlak.23-Jul-09 18:10 
AnswerRe: How would one go about doing this? (Code Coverage) Pin
S. Senthil Kumar24-Jul-09 5:35
S. Senthil Kumar24-Jul-09 5:35 
QuestionOnDeserialized/OnDeserializing not firing Pin
RichardM123-Jul-09 5:59
RichardM123-Jul-09 5:59 
AnswerRe: OnDeserialized/OnDeserializing not firing Pin
Vova Gaevoy15-Jul-10 4:33
Vova Gaevoy15-Jul-10 4:33 
QuestionSCSF Smart Client application takes time to load Pin
Sakshi Smriti23-Jul-09 2:02
Sakshi Smriti23-Jul-09 2:02 
AnswerRe: SCSF Smart Client application takes time to load Pin
Ian McCaul23-Jul-09 8:23
Ian McCaul23-Jul-09 8:23 
QuestionRelated value in Datagridviewcolumn Pin
Sergiev23-Jul-09 1:37
Sergiev23-Jul-09 1:37 
AnswerRe: Related value in Datagridviewcolumn Pin
amit k mistry23-Jul-09 6:53
amit k mistry23-Jul-09 6:53 
GeneralRe: Related value in Datagridviewcolumn Pin
Sergiev23-Jul-09 10:04
Sergiev23-Jul-09 10:04 
GeneralRe: Related value in Datagridviewcolumn Pin
Infarkt25-Jul-09 15:29
Infarkt25-Jul-09 15:29 
QuestionOleDbParameter and "IS NOT NULL" Pin
:o:k:23-Jul-09 0:32
:o:k:23-Jul-09 0:32 
AnswerRe: OleDbParameter and "IS NOT NULL" Pin
:o:k:24-Jul-09 3:02
:o:k:24-Jul-09 3:02 
AnswerRe: OleDbParameter and "IS NOT NULL" Pin
Jack Vanderhorst25-Jul-09 4:20
Jack Vanderhorst25-Jul-09 4:20 

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.