directoryservices

System.DirectoryServices.AccountManagement.PrincipalContext and Impersonation in a WCF service

荒凉一梦 提交于 2020-01-03 19:16:43
问题 Working with the PrincipalContext in code that lies behind a WCF service. The WCF service is impersonating, to allow a 'pass-through' type authentication. While everything else I do with Active Directory (mostly the System.DirectoryServices.Protocols namespace) works fine in this scenario, for some reason the classes in System.DirectoryServices.AccountManagement throw a fit. Sample code that fails: PrincipalContext context = new PrincipalContext(ContextType.Domain, domainName); UserPrincipal

PermissiveModifyControl throws DirectoryOperationException in C# LDAP

限于喜欢 提交于 2020-01-03 18:45:35
问题 Using the System.DirectoryServices.Protocols namespace to add/modify attributes on an Active Directory group. Code: public void UpdateProperties(Dictionary<string, string> Properties) { List<DirectoryAttributeModification> directoryAttributeModifications; // ... Code to convert Properties dictionary to directoryAttributeModifications // There is one 'Add' modification, to set the 'description' of the group ModifyRequest modifyRequest = new ModifyRequest(groupDistinguishedName,

PermissiveModifyControl throws DirectoryOperationException in C# LDAP

早过忘川 提交于 2020-01-03 18:45:33
问题 Using the System.DirectoryServices.Protocols namespace to add/modify attributes on an Active Directory group. Code: public void UpdateProperties(Dictionary<string, string> Properties) { List<DirectoryAttributeModification> directoryAttributeModifications; // ... Code to convert Properties dictionary to directoryAttributeModifications // There is one 'Add' modification, to set the 'description' of the group ModifyRequest modifyRequest = new ModifyRequest(groupDistinguishedName,

What are the different properties available in System.DirectoryServices.DirectorySearcher.PropertiesToLoad

♀尐吖头ヾ 提交于 2020-01-02 01:10:17
问题 Everything I've googled just says you can add them as a string array, but doesn't say what the available options are. What are all the different properties that are available from Directory Services? 回答1: You can put any of the valid LDAP attributes into PropertiesToLoad - see a list of all Active Directory attributes here - what you need is the Ldap-Display-Name for each attribute you're interested in. Also: Richard Mueller has a site with lots of good info on AD and LDAP - including Excel

ASP.NET MVC Windows Authentiaction and DirectoryServices - Get Mail Address of the current user throws an InvalidCastException

 ̄綄美尐妖づ 提交于 2020-01-01 11:55:16
问题 I am using ASP.NET MVC 4 and Windows Authentication. When I am using VisualStudio everything works fine, but when I deploy my site an exception is thrown. var emailAddress = UserPrincipal.Current.EmailAddress; throws: Unable to cast object of type 'System.DirectoryServices.AccountManagement.GroupPrincipal' to type 'System.DirectoryServices.AccountManagement.UserPrincipal'. The rest works fine. Users can authenticate and I can get the users name etc. EDIT: I enabled Impersonation on IIS. Now I

System.DirectoryServices is not recognised in the namespace 'System'

爷,独闯天下 提交于 2019-12-31 17:50:17
问题 I'm trying to use System.DirectoryServices in a web site project and I'm getting this error: The type or namespace name 'DirectoryServices' does not exist in the namespace 'System' (are you missing an assembly reference?) My project has a reference to System.DirectoryServices in web.config : <add assembly="System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/> And I do have using System.DirectoryServices in the files where I want to use it. Does anybody

Create an application pool that uses .NET 4.0

余生颓废 提交于 2019-12-31 10:07:18
问题 I use the following code to create a app pool: var metabasePath = string.Format(@"IIS://{0}/W3SVC/AppPools", serverName); DirectoryEntry newpool; DirectoryEntry apppools = new DirectoryEntry(metabasePath); newpool = apppools.Children.Add(appPoolName, "IIsApplicationPool"); newpool.CommitChanges(); How do I specify that the app pool should use .NET Framework 4.0? 回答1: I see from the tags you're using IIS7. Unless you absolutely have to, don't use the IIS6 compatibility components. Your

Create an application pool that uses .NET 4.0

醉酒当歌 提交于 2019-12-31 10:07:06
问题 I use the following code to create a app pool: var metabasePath = string.Format(@"IIS://{0}/W3SVC/AppPools", serverName); DirectoryEntry newpool; DirectoryEntry apppools = new DirectoryEntry(metabasePath); newpool = apppools.Children.Add(appPoolName, "IIsApplicationPool"); newpool.CommitChanges(); How do I specify that the app pool should use .NET Framework 4.0? 回答1: I see from the tags you're using IIS7. Unless you absolutely have to, don't use the IIS6 compatibility components. Your

Difference between PrincipalSearcher and DirectorySearcher

大憨熊 提交于 2019-12-31 08:14:08
问题 I see Active Directory examples that use PrincipalSearcher and other examples that do the same thing but use DirectorySearcher . What is the difference between these two examples? Example using PrincipalSearcher PrincipalContext context = new PrincipalContext(ContextType.Domain); PrincipalSearcher search = new PrincipalSearcher(new UserPrincipal(context)); foreach( UserPrincipal user in search.FindAll() ) { if( null != user ) Console.WriteLine(user.DistinguishedName); } Example using

Problems with Directory Services and Account Management in ASP.NET Core

梦想的初衷 提交于 2019-12-31 00:50:56
问题 I have a ASP.NET Core API project and I'd like to utilize DirectoryServices and DirectoryServices.AccountManagement namespaces. After some research I thought I found some project.json references that would work: { "version": "1.0.0-*", "compilationOptions": { "emitEntryPoint": true }, "dependencies": { "EntityFramework.Commands": "7.0.0-rc1-final", "EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final", "EntityFramework.MicrosoftSqlServer.Design": "7.0.0-rc1-final", "Microsoft.AspNet