directoryservices

Setting Group Type for new Active Directory Entry in VB.NET

I'm trying to set the group type for a new Active Directory Entry via VB.NET and DirectoryServices to create a distribution list. How do I access the ADS_GROUP_TYPE enumerations? Specifically I'm after ADS_GROUP_TYPE_GLOBAL_GROUP. ...

Authenticating Domain Users with System.DirectoryServices

Given a username and a password for a domain user, what would be the best way to authenticate that user programatically? ...

How do you backup IIS's metabase in C#?

exact code will be helpful. I assume the DirectoryServices namespace does it but I can't find the method that does it. ...

Using ActiveDirectoryMembershipProvider with two domain controllers

We have an ASP.NET application running at a customer site that uses ActiveDirectory for user login via the ActiveDirectoryMembershipProvider. Their primary domain controller that we were pointing to went down this morning, and in getting everything set back up the client was wondering if we could have a redundant connection to two domain...

DirectoryEntry.NativeObject throws access denied for a user in Administrators group in windows 2008

I have a local user, which is member of Administrators local group. When I run this code: using System; using System.DirectoryServices; namespace nanttest { class Program { public static void Main(string[] args) { using(DirectoryEntry entry = new DirectoryEntry("IIS://localhost/W3SVC")) { object ab...

System.DirectoryServices problem

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, Versi...

Unable to turn on SecureSocketLayer with DirectoryServices.Protocols.LdapConnection

I am trying to fix a bug with SSL in a product and noticed that although the code sets SSL to be true, in the next line in the code SSL is still at false. I wrote a unit test for this and the unit test confirms my suspicions. [TestMethod] public void SecureSocketLayerSetToTrue( ) { var ldapConnection = new LdapConnection( ...

Crashing with C# and Directory Services on XP

I'm trying to do some simple data retrieval with C# and Directory Services, but for some reason it doesn't work on any XP machines. If I run my code on a Server 2003 machine, there are no problems. I've spent a fair bit of time trying to find out if maybe there's some redistributable I need on XP or if the functionality simply isn't ther...

Request a user's roles in AD when caller is not in domain

I would like to get a user's group memberships in an ActiveDirectory, without being in the domain. When I run this inside the domain, all is well. var context = new PrincipalContext(ContextType.Domain); var principal = UserPrincipal.FindByIdentity(context, IdentityType.Name, "administrator"); foreach (var authorizationGroup in principa...

"Domain Users" group is empty when I use DirectoryServices "member" property

I'm using the following code to get the members of a group on my domain: Dim de As New DirectoryEntry("LDAP://" & GroupDN) For Each user As String In CType(de.Properties("member"), IEnumerable) GroupCollection.Add(Username, Username) Next My problem is that when GroupDN (the distinguishedname of the group) is "CN=Do...

"new DirectoryEntry(distinguishedName as string)" doesn't work when DN contains a "/"

I have the following code to convert a distinguishedName to a sAMAccountName: Dim de As New DirectoryEntry("LDAP://" & stringDN) Return CType(de.Properties("samaccountname")(0), String) It works great for every DN I pass it, except for one. We have an AD group on our domain that has a "/" in it - call it "Programmers/DBAs". The DN for...

System.DirectoryServices pegs my processor when multi-threaded - can I lower the burden?

My application takes the currently logged-in user and uses an a DirectoryServices.DirectorySearcher to pull a few additional detail about them (some properties we have stored in a few custom AD fields, as well as their email address). This works great, though I've always though it was a little slow - my single-threaded code could only ma...

How do I determine the ASP.NET version of a virtual directory or website using C# ?

How do I find out the .NET framework of an IIS virtual directory is using in C#. I need to display it to the user. using System.DirectoryServices; using System.IO; private enum IISVersion { IIS5, IIS6 } private void ReadVirtualDirectory(string server, string directory, IISVersion version) { string siteID = string.Empty; ...

"Access Denied" when trying to connect to remote IIS server - C#

I receive an "Access Deined" COMException when I try to connect to a remote IIS 6 server from my C# application that is running under IIS 5.1. Any ideas? I am experiencing all the same issues with the original questions. Update - 4/1/09 I found this solution (http://www.codeproject.com/KB/cs/Start_Stop_IIS_Website.aspx) that consists...

How do I determine if an "IIsWebDirectory" or "IIsWebVirtualDir" is an ASP.NET Application?

I am currently writing an C# asp.net application to connect to an IIS server and query the virtual directory/web directory information. I am able to determine that there are that two types I should be dealing with is an "IIsWebDirectory" and "IIsWebVirtualDir". How to I determine if they have been configured to be an "application" in C...

How do I loop through a PropertyCollection - C#

Can anyone provide an example of how to loop through a System.DirectoryServices.PropertyCollection and output the property name and value? I am using C#. @JaredPar - The PropertyCollection does not have a Name/Value property. It does have a PropertyNames and Values, type System.Collection.ICollection. I do not know the basline object...

Looping through DirectoryEntry or any object hierarchy - C#

I am currently developing an application that use the System.DirectoryServices namespace to create a DirectoryEntry object and loop through the entire hierarchy to collect information. I do not know number of child entries for each DirectoryEntry object in the hierarchy, so I can not create a N number of nested loops to spiders throug...

DirectoryServices.AccountManagement "old" password still validates after password change.

After resetting a users password in Active Directory, if the user tries to log in using their old password, the following code validates as True: Dim up As UserPrincipal = GetAdUser(objContext, arg_strBA, arg_strUsername) If up IsNot Nothing Then Dim valid As Boolean = up.Context.ValidateCredentials( up.UserPrincipalName, arg_...

directory services group query changing randomly

I am receiving an unusual behaviour in my asp.net application. I have code that uses Directory Services to find the AD groups for a given, authenticated user. The code goes something like ... string username = "user"; string domain = "LDAP://DC=domain,DC=com"; DirectorySearcher search = new DirectorySearcher(domain); search.Filter = "...

Authenticating an ADAM user against ADAM from C# - cannot bind

I have set up an ADAM instance and added some test users. From c# I can bind to ADAM using a windows account but I cannot bind using one of the ADAM users. (I can successfully bind the adam users in ldp) & I have made sure the users are enabled by setting msDS-UserAccountDisabled attribute to false. When I bind with my windows account I...