-
June 22nd, 2015, 09:31 AM
#1
Newbie in C sharp/ Microsoft Visio
Hi Guys,
I am attempting to run a code to output the username and accountLockoutTime in Active Directory. But I'm facing errors in the initial phases of the code.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication4
{
class Program
{
public void Main ()
{
PrincipleContext ctx = new PrincipleContext (ContextType.Domain "number")
The error coming is in using "PrincipleContext" :
1. The type or namespace name "PrincipleContext" could not be found. Are you missing a using directive or an assembly reference? For this I added the System COnfiguration .NET reference and still error
2. Only assignment, call, increment, decrement and new object expressions can be used as a statement.
-
June 22nd, 2015, 09:32 AM
#2
Re: Newbie in C sharp/ Microsoft Visio
Also the "number" after domain is a binary number I do not want to disclose so for the purposes of this thread I just wrote number
-
June 22nd, 2015, 09:44 AM
#3
Re: Newbie in C sharp/ Microsoft Visio
Okay so I've got it to define PrincipleContext but it is not defining ContextType saying that it doesn't exist in the current context?
What does that mean?
-
June 22nd, 2015, 12:55 PM
#4
Re: Newbie in C sharp/ Microsoft Visio
Originally Posted by kiwi101
1. The type or namespace name "PrincipleContext" could not be found. Are you missing a using directive or an assembly reference? For this I added the System COnfiguration .NET reference and still error
System.Configuration has nothing to do with security. When you are using unfamiliar C# classes and need to find which assembly to reference, just look it up in msdn. For each class in msdn, you'll find the Namespace and Reference to use.
PrincipalContext Class in msdn.
From the link...
Namespace: System.DirectoryServices.AccountManagement
Assembly: System.DirectoryServices.AccountManagement (in System.DirectoryServices.AccountManagement.dll)
-
June 23rd, 2015, 06:54 AM
#5
Re: Newbie in C sharp/ Microsoft Visio
Also, after you add assembly & namespace references as described above, check you code for typos and syntax errors (there are both in the code you posted above):
PrincipleContext ctx = new PrincipleContext (ContextType.Domain "number")
should be
PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "number");
Last edited by TheGreatCthulhu; June 23rd, 2015 at 06:56 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|