Question: I keep getting this error in SQLite: 

> 
> Query Error: near "FROM": syntax error Unable to execute statement
> 
> 
> 

```
SELECT Name, CourseId
    FROM Lecturer JOIN Lecture ON Lecturer.LecturerId = Lecture.LecturerId
    JOIN     (SELECT CourseId   
        FROM Course
        WHERE EXISTS (SELECT * 
                    FROM Exam
                WHERE Exam.CourseId = Course.CourseId
                AND (SELECT COUNT *
                          FROM Exam
                          WHERE Grade > 6)
                <
                (SELECT COUNT *
                FROM Exam
                WHERE Grade < 6)))
    USING Course.Id     

```

Answer: 
```
void Main()
{
    string groupName = "somegroup";
    string domainName = "somedomain";

    using(PrincipalContext ctx = new PrincipalContext(ContextType.Domain, domainName))
    {
        using(GroupPrincipal grp = GroupPrincipal.FindByIdentity(ctx, IdentityType.Name, groupName))
        {
            var sams = from x in grp.GetMembers(true) select new {x.SamAccountName, };
            var users = from sam in sams.Distinct()
                let usr = UserPrincipal.FindByIdentity(ctx, IdentityType.SamAccountName, sam.SamAccountName)
                select new { usr.SamAccountName, usr.DisplayName, usr.EmailAddress};
            //do something with users...
        }
    }
}

```
in this url are a good and complete articule about AD with C# <http://www.codeproject.com/Articles/18102/Howto-Almost-Everything-In-Active-Directory-via-C#42>, user are stored as DiretoryEntry review the property Properties
<http://msdn.microsoft.com/en-us/library/system.directoryservices.directoryentry.properties(v=vs.100).aspx>