{"id":30200848,"url":"https://github.com/dapplo/dapplo.activedirectory","last_synced_at":"2025-09-01T05:37:56.319Z","repository":{"id":61349753,"uuid":"49208105","full_name":"dapplo/Dapplo.ActiveDirectory","owner":"dapplo","description":"A library which helps you with Active Directory access","archived":false,"fork":false,"pushed_at":"2022-10-18T09:31:30.000Z","size":756,"stargazers_count":5,"open_issues_count":5,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-13T09:48:38.145Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dapplo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"lakritzator","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"custom":null}},"created_at":"2016-01-07T14:06:53.000Z","updated_at":"2022-10-13T11:56:49.000Z","dependencies_parsed_at":"2023-01-20T05:16:43.824Z","dependency_job_id":null,"html_url":"https://github.com/dapplo/Dapplo.ActiveDirectory","commit_stats":null,"previous_names":[],"tags_count":36,"template":false,"template_full_name":null,"purl":"pkg:github/dapplo/Dapplo.ActiveDirectory","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dapplo%2FDapplo.ActiveDirectory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dapplo%2FDapplo.ActiveDirectory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dapplo%2FDapplo.ActiveDirectory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dapplo%2FDapplo.ActiveDirectory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dapplo","download_url":"https://codeload.github.com/dapplo/Dapplo.ActiveDirectory/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dapplo%2FDapplo.ActiveDirectory/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273077227,"owners_count":25041358,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-01T02:00:09.058Z","response_time":120,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-08-13T09:41:23.445Z","updated_at":"2025-09-01T05:37:56.302Z","avatar_url":"https://github.com/dapplo.png","language":"C#","funding_links":["https://github.com/sponsors/lakritzator"],"categories":[],"sub_categories":[],"readme":"# Dapplo.ActiveDirectory\nA library for easy Active Directory access\n\n- Documentation can be found [here](http://www.dapplo.net/Dapplo.ActiveDirectory)\n- Current build status: [![Build Status](https://dev.azure.com/Dapplo/Dapplo%20framework/_apis/build/status/dapplo.Dapplo.ActiveDirectory?branchName=master)](https://dev.azure.com/Dapplo/Dapplo%20framework/_build/latest?definitionId=15\u0026branchName=master)\n- Coverage Status: [![Coverage Status](https://coveralls.io/repos/github/dapplo/Dapplo.ActiveDirectory/badge.svg?branch=master)](https://coveralls.io/github/dapplo/Dapplo.ActiveDirectory?branch=master)\n- NuGet package: [![NuGet package](https://badge.fury.io/nu/Dapplo.ActiveDirectory.svg)](https://badge.fury.io/nu/Dapplo.ActiveDirectory)\n\nAlthough it's not extremely hard to access the Active Directory from .NET, sometimes a little bit of help is nice.\n\nThe idea behind this library is that you can build queries via a fluent API (some shortcuts available).\nAnd you don't need to understand all of the details of the Active Directory.\n\nFluent API:\n```\n\tvar query = Query.AND.Where(\"objectClass\", \"user\", Comparisons.EqualTo).Where(UserProperties.Username, Environment.UserName, Comparisons.EqualTo);\n```\nEasier readable:\n```\n\tvar query = Query.AND.WhereIsUser().WhereEqualTo(UserProperties.Username, Environment.UserName);\n```\nShortest version:\n```\n\tvar query = Query.ForUser(Environment.UserName);\n```\n\nOr query for at all the active users that have a telephone number:\nComplete version\n```\n\tvar query = Query.AND.Where(\"objectClass\", \"user\", Comparisons.EqualTo).WhereNot(Property.BitAnd(UserProperties.UserAccountControl), (int)UserAccountControlFlags.AccountDisabled).Where(UserProperties.TelephoneNumber, Value.Any, Comparisons.EqualTo);\n```\nShortest version:\n```\n\tvar query = Query.ForUser().WhereAccountEnabled().WhereAny(UserProperties.TelephoneNumber);\n```\n\nThe properties are defined via enums, some are already pre-defined in the library, but you can use any enum you like.\nEither the Enum value is the property name in the AD, or you can use EnumValue attribute on your enum value to mark the property name.\n\nHere is an enum example:\n```\n\tpublic enum UserProperties\n\t{\n\t\t[EnumMember(Value = \"displayName\")]\n\t\tDisplayName,\n\t\t[EnumMember(Value = \"memberOf\")]\n\t\tMemberOfGroups,\n\t\t[EnumMember(Value = \"sAMAccountname\")]\n\t\tUsername,\n\t\t\n\t\t...\n\t}\n```\n\nNow, we can use this enum in the query but also to define a result object (use interfaces) like this:\n```\n\tpublic interface IUserInfo : IAdObject\n\t{\n\t\t[AdProperty(UserProperties.DisplayName)]\n\t\tstring Name { get; set; }\n\n\t\t[AdProperty(UserProperties.MemberOfGroups)]\n\t\tIList\u003cDistinguishedName\u003e Groups { get; set; }\n\t\t\n\t\t...\n\t}\n```\n\nGet your user info object from the current domain:\n```\n\tforeach(var user in query.Execute\u003cIUserInfo\u003e()) {\n\t\tConsole.WriteLine(user.Name);\n\t}\n```\nShort explanation: Execute is called, as an extensions method, on the query and the result type is specified.\nTo be able to tell the AD what it needs to return, it will take the properties from the type.\nThe result from the AD, with use of the properties, is than mapped into instances of your result type.\n\nChanging values in the active directory is possible, but is far from completed, and works as follows:\nAdd ONE property marked with [AdProperty(AdProperties.Id)] to your result object.\nQuery for the information you want to change, change the properties and call the ActiveDirectoryExtensions.Update(object, string domain) method.\nIt will update all the values that are writable, but there is no conversion in the code yet so it will not always work.\n\nNotes:\nThere is no support yet for a single value query, but this should not be used anyway for performance reasons.\nThe property names and values are specials classes with implicit cast from enum \u0026 string, said differently: you can use enums and strings mixed.\nThese classes can help with using special values, like Value.StartsWith and Value.Endwith...\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdapplo%2Fdapplo.activedirectory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdapplo%2Fdapplo.activedirectory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdapplo%2Fdapplo.activedirectory/lists"}