directoryservices

C# 3.0: Find SMTP Servers within a Domain

I'm using C# 3.0 and the System.DirectoryServices namespace (not the newer System.DirectoryServices.AccountManagement namespace of .NET 3.5). How can I find all of the SMTP Servers on the local domain? Is this even possible? Is there another way to accomplish this? ...

What is the NativeGuid in DirectoryEntry when querying via the WinNT provider?

I'm writing an application which I want to work with both Active Directory and local users and groups. I thought I could use the NativeGuid property of a DirectoryEntry as a unique identifier which was retrieved using the WinNT provider against LocalHost. However, using the following code in LinqPad I get the same NativeGuid for both en...

AD group name with '/' character is blowing up my binding

I get the memberOf property for my user using this code: DirectorySearcher search = new DirectorySearcher(new DirectoryEntry(connectionString)); search.Filter=string.Format("(&(sAMAccountName={0})(objectClass=user))",userName); SearchResult result = search.FirndOne(); So far so good. However I then have to get the cn value for each gr...

Why would this catch all block not in fact catch all

The code is fairly simple --- the issue is that there is an invalid character in the groupPath string (a '/' to be exact). What I'm trying to do (at least as a stop gap) is skip over DirectoryEntries that I can't get the cn for --- regardless of why. However when I run this code the catch block doesn't run and I get instead: The server...

How do I add a user to AD using System.DirectoryServices.AccountManagement?

Using the .net 3.5 framework and C# I'm trying to add a new user to AD from C# and can't find any examples. I see that the PrincipalCollection object has an overloaded 'add' method but can't seem to figure out how it works. Can anyone help? How create a new user object, add it into AD. Secondly, the user that will be adding in new...

System.DirectoryServices.AccountManagement in .net 2.0

Is there a: string name = System.DirectoryServices.AccountManagement.UserPrincipal.Current.DisplayName; equivalence in .net 2.0 framework? It uses the System.DirectoryServices.AccountManagement (ver 3.5) reference. I tried using that file on a .net 2.0 framework but to no avail. Basically, I want to retrieve the full username (f...

Detect read-only domain controller with .NET?

I want to be able to determine whether a particular domain controller is read-only. I know I can do stuff like this to get a writeable DC: using( Domain d = Domain.GetCurrentDomain() ) { DomainController dc = d.FindDomainController( "mysitename", LocatorOptions.WriteableRequired); } But given a DomainController object is...

vb.net active directory question - rename user account and mailbox

I'm trying to rename a user programically and can't figure out the mailbox piece(proxyAddresses). Any help is appreciated... Working code below... Public Shared Function renameUser(ByVal curUsername As String, ByVal newUsername As String) As Boolean Dim emailSuffix As String = "@here.com" Dim userPrincipalSuffix As String = "@...

Randomly select a record from Active Directory Application Mode

I need a routine to randomly select records from ADAM (Active Directory Application Mode). Any advice to get me started on this task? ...

How to programaticly change Active Directory password.

I have a set of test accounts that are going to be created but the accounts will be setup to require password change on the first login. I want to write a program in C# to go through the test accounts and change the passwords. ...

Guidelines to follow when making your program Active Directory/Terminal Services compatible

Wondering if there's any guidelines that should be followed when writing an application that should work not only on a plain ol' non-networked computer but also on a computer/network that is setup with Active Directory (or some other directory service) and/or Terminal Services? Anything I should look out for, be aware of, etc? ...

How to change System.DirectoryEntry "uSNChanged" attribute value to an Int64

I'm trying to get the Int64 value of a Directory Services object's "uSNChanged" value. Unfortunately, it is always coming back as a COM object of some kind. I've tried using casting to Int64, calling Int64.Parse(), and calling Convert.ToInt64(). None of these work. For a given DirectoryEntry object, this code will display the properties...

is DirectorySearcher.SizeLimit = 1 for FindAll() equal to FindOne() [DirectoryServices/.net]

When using the DirectorySearcher in .net, are these two statements equal? Same for both: Dim ds As New DirectorySearcher ' code to setup the searcher First statement ds.FindOne() Second statement ds.SizeLimit = 1 ds.FindAll() ...except obviously that FindOne() returns a SearchResult object and FindAll() returns a SearchResultCo...

Does SearchResultCollection's GetDirectoryEntry have to query ActiveDirectory again? [DirectoryServices/.net]

When using the FindAll() method of the DirectorySearcher in .net, does the GetDirectoryEntry() method of the SearchResultCollection require another trip to Active Directory? e.g.... Dim src As SearchResultCollection Dim ds As New DirectorySearcher ' code to setup DirectorySearcher ' go to Active Directory and fill collection with resu...

How to abandon a long-running search in System.DirectoryServices.Protocols

I've been trying to work out how to cancel a long-running AD search in System.DirectoryServices.Protocols. Can anyone help? I've looked at the supportControl/supportedCapabilities attributes on RootDSE and they don't contain the 1.3.6.1.1.8 OID so I think that means it doesn't support the LDAP CANCEL extended operation as defined here:...

can a user be part of multiple subtree in a (Ldap based) Directory Service instance ?

Hi, I am pretty new to the ldap based directory service programming using .net framework; hence have a basic silly question. I would like to find out the all sub trees a particular user belongs to using System.DirectoryServices.Protocol. First of all , Can a User be part of the multiple Sub Trees in “a” directory service instance? If ...

FindByIdentity in System.DirectoryServices.AccountManagment Memory Issues

I'm working on an active directory managament application. In addition to the typical Create A New User, Enable/Disable an account, reset my password etc. it also managages application permissions for all of the clients web applications. Application management is handled by thousands of AD groups such as which are built from 3 letter c...

Connecting to LDAP from C# using DirectoryServices.

Hi, I am trying to connect to an edirectory 8.8 server running LDAP. How would I go about doing that in .Net? Can I still use the classes in System.DirectoryService such as DirectoryEntry and DirectorySearcher or are they AD specific? Do I need to specify the "Connection String" any differently? I am trying something like the code bel...

Using DirectorySearcher to query multiple OUs

I have the following code: var directoryEntry = new DirectoryEntry(distributionListsListADSPath); var directorySearcher = new DirectorySearcher(directoryEntry) { SizeLimit = int.MaxValue, PageSize = int.MaxValue }; var result = directorySearcher.FindAll(); The problem is I want to search two seperate OUs. So what I do is r...

How to change passwords using System.DirectoryServices.Protocols

Our user store is an LDAP server called eDirectory. How do you change user passwords using System.DirectoryServices.Protocols? ...