directoryservices

Searching for a objectGUID in AD

I'm using the Active Directory Explorer from Mark Russinovich. It is a great tool. I'm using it to navigate active directory to make sure my program that uses DirectorySearcher from .NET returns correct data. Something happens though, when I try to search inside my program with DirectorySearcher for objectGUID, if I pass in the actual ...

Does System.DirectoryServices.DirectoryEntry contain a constructor that actually uses "domain\username" with Ldap?

Microsoft has a general purpose KB article (Q316748) describing how to authenticate against Active Directory using the DirectoryEntry object. In their example they produce a username value by concatenating the domain name and username into the standard NetBIOS format("domain\username") and passing that as a parameter to the directory ent...

"The specified domain either does not exist or could not be contacted"

I'm trying to use Integrated Windows Authentication combined with a DirectorySearcher to identify and authenticate the intranet user. I'd managed to get some fairly simple code that seemed to do the trick, but when I tried on the live server I get the following error: "The specified domain either does not exist or could not be contacte...

How to list all computers and the last time they were logged onto in AD?

I am trying to retrieve a list of Computer Names and the date they were last logged onto from Active Directory and return them in a datatable. Getting the names is easy enough but when I try to add the "lastLogon" or "lastLogonTimestamp" like shown below, the only values I get for the lastLogonTimestamp is "System._ComObject" public Dat...

Error 0x80005000 and DirectoryServices

I'm trying to run a simple LDAP query using directory services in .Net. DirectoryEntry directoryEntry = new DirectoryEntry("LDAP://someserver.contoso.com/DC=contoso,DC=com"); directoryEntry.AuthenticationType = AuthenticationTypes.Secure; DirectorySearcher directorySearcher = new DirectorySearcher(directoryEntry); dire...

asp.net iis metabase doesn't return all sites

Hi, I use code like the following in ASP.Net to enumerate the websites in IIS: string metabasePath = "IIS://localhost/W3SVC"; DirectoryEntry service = new DirectoryEntry(metabasePath); service.RefreshCache(); string className = service.SchemaClassName.ToString(); if (className.EndsWith("Service")) { DirectoryEntries sites = servi...

Alternative to installing IIS locally to access IIS remotely?

I have an app that accesses information about websites running on IIS on a remote machine, using DirectoryEntry objects (in System.DirectoryServices). Any client machine that runs the app needs to have IIS installed or the app throws a System.Runtime.InteropServices.COMException when it accesses the IIS information. Is there a way I ca...

Get Directory from User

I'm looking for a function to get a directory path from the user; I need to solicit a place to put things. I tried using GetOpenFileName() with .dir as a filter but no joy. I found something called GetDirectoryViaBrowse() that sounds like it might do what I want but it's part of some wizard making package and my Visual Studio knows not...

Building a simple security sandbox on Windows 2008 by automatically creating & restricting user accounts?

I want to build a fairly simple security sandbox for an application hosting service - the main goals are thus: Applications running "in" the sandbox cannot install anything onto the system outside of the directory the executable is running in. Access to the system in general is denied (registry access, et al.). Access to the file syste...

Get an application pool's Process ID using ADSI

Hi all, I've wrote a small tool that lists all the app pools running on a box and allows you to start/ stop/ recycle them. I've used System.DirectoryServices. Now I'm trying to get it to write out the ProcessID of each AppPool for use in another tool but I'm struggling to find where it is / how to access it. Does anyone have any pointe...

Active Directory not finding all users in C#

I have some code that queries Active Directory to verify user existence. I am trying to verify a long list of about 1300 ids. I've tried several methods to verify if a user account (LINQ to AD, DirectorySearcher (with and without a parent DirectoryEntry) and also a DirectoryEntry that links to the WinNT:// path). Every time it will co...

Enumerate Windows user group members on remote system using vb.net

I am trying to do the same thing in vb.net as the op in this post see below but I would like to do it using System.directoryservices method just like he mentioned later in the post. i don't see why i can't since I am able to add a user to the admin group using DS method. ex. Public Shared Sub AddAdminAccount(ByVal username As Str...

Strange issue with System.DirectoryServices.AccountManagement.UserPrincipal.FindByIdentity

We're writing a system that allows a user to change their account password through a web application on our intranet. At first, everything appeared to be running smoothly. During development passwords for our test accounts could be changed with no problem. When we made the system live, however, we started running into issues. Here are...

Get Groups From OU using DirectoryServices.AccountManagement

Hello, I'd like to use AccountManagement to list all the groups in an Organizational Unit. The following snippet works with DirectoryServices but I would have to instanciate GroupPrincipal with the DirectoryEntry path in the result (which feels like a dirty fix). DirectoryEntry root = new DirectoryEntry("LDAP://OU=Marketing,OU=Operat...

LDAP Query with sub result

I have been banging my head for quite a while with this and can't get it to work. I have a LDAP Query I do have working in AD Users and Computers but dont know how to do it programatically in C#. Here are my LDAP Query that works fine in the AD Tool: (memberOf=CN=AccRght,OU=Groups,OU=P,OU=Server,DC=mydomain,DC=com)(objectCategory=user)(...

Managing terminal users through System.DirectoryServices

I have a environment where I need to frequently change the parameters to a program that is launched when a user logs in to the terminal server. As of right now we open the computer management snap-in and edit the environment tab for the user and change the parameters by hand under "Start the following program at logon:". I would like to ...

How to determine if user account is enabled or disabled

I am throwing together a quick C# win forms app to help resolve a repetitive clerical job. I have performed a search in AD for all user accounts and am adding them to a list view with check boxes. I would like to default the listviewitems' default check state to depend upon the enabled/disabled state of the account. string path = "LDA...

Unable to response quickly to AD retrieval

Hi, I am developing a SharePoint application which needs users from a specified Windows Server 2003 Active Directory Organizational Unit. Firstly I wasn't concerned about the 'Dispose' and 'Close' operations on DirectoryServices objects. In this point the retrieve operations were quick and successful. But this was causing 'Server is...

is System.DirectoryServices.AccountManagement.GroupPrincipal thread safe?

I am writing a program that will create users in bulk, I have a operation that is part of the creation that is blocks for about 5 seconds, to get around this I was going to make it threaded and have everything sitting in a thread pool. My question is if I create the principle outside the thread and pass the group principle to the thread...

How to Marshal COM simple type -> net type

I need to determine value of (DirectoryEntry) user.Propertes["pwdLastSet].Value how would I marshal such value to .Net Type.. ...