active-directory

C# Testing for null

I'm using C# to write a simple program to read Active Directory and display the value held in a AD field on a Windows form program. If a property doesn't exist then the program crashes, below is my code, how can I catch this and move on to the next field without doing a try/catch for each and every attribute? DirectoryEntry usr = new D...

Adding Active Directory sub domain user to main domain group

I have a function that works perfectly when I attempt to add a user from the same domain into a group of the same domain. Function AddUserToGroup(ByVal strUserDN As String, ByVal strGroupDN As String, ByVal strGRPDC As String, ByVal strUserDC As String) As Boolean Dim oUser As DirectoryEntry Dim oGroup As DirectoryEntry Dim ...

Modifying script with Recursive queries

Good morning all, I need help to add the following additions to a script. 1) Recursive queries (e.g if a group is contained in a group it doesn’t go into that and retrieve all the members) 2) Instead of looking for the AllowLogon right look for memberOf the Terminal Services group The goal is to show all the active acco...

IPrincipal.IsInRole() only works when I truncate the role names - why?

I have an application that relies heavily on authorization of users. Within it, I am using IPrincipal.IsInRole() to check whether users are in the correct groups: IPrincipal principal = Thread.CurrentPrincipal; bool inRole = principal.IsInRole("mydomainname\some role with a long name"); This works fine for the most part, but fails (re...

how to remove user account from active directory in asp.net

Hi All, how to remove user account from active directory programmatically in asp.net? Please help me id this. Regards, Abhimanyu ...

List of computers in Active Directory that are online

I'm using this snippet of code to output a list of all the computers on my network (the language is jscript.net, but it's just a small manipulation of C#). var parentEntry = new DirectoryEntry(); parentEntry.Path = "WinNT:"; for(var childEntry in parentEntry.Children) { if(childEntry.SchemaClassName == "Domain") { ...

Which account do I use to query Active Directory?

To use Windows Authentication in our asp.net application, we need to check the Active Directory. To test, I normally use my own account, but that means that anyone can see my password on our buildserver. Which account do I best use for this purpose? A restricted account in Active Directory? ...

Output domain COMPUTERNAME and logged in USERNAME spreadsheet

So the boss asked for a spreadsheet that would show him all the computers in our enterprise and the users that are currently logged in. I stopped asking "why?" and started with NBTSTAT. The <03> results were inconsistent. Then I tried NET CONFIG WORKSTATION, and finally PSLOGGEDON.EXE (SYSINTERNALS). These were good, but I'd have to fin...

Custom schema template/class in Active Directory using C#

Hi I need to distribute a string-value (a wcf-service-address) to a network of clients in the same domain. I figured AD would be a good place to store this kind of information, or is it overkill for only one string-value? To do this it seems I have to add a custom AD-class/schema template. But how? I can't find any good information abo...

.NET : Transmit user credentials over the transport layer

What is the best/simplest way to transmit the user credentials (Active Directory) over the transport layer. I have two systems A and B connected with a 3rd party message layer C. Is there any way (preferable in .NET) to somehow store/serialize the credentials of the authenticated user on the side A, transmit it over the C, then to de-s...

Getting user password from Active Directory

I am using active directory in my ASP.NET project and whenever user register in the site,an account is created in AD. There is an Forgot Password link.Is it possible to get user password from AD.I can get the name or email, but I don't know if I can get the password. Regards, Abhimanyu ...

When you set a web directory property "AuthNTLM" using the DirectoryEntry object, what IIS setting are you actually changing?

I'm in task of migrating our product's installer from InstallShield to WiX. To deploy web applications, the previous developers used Custom Actions (written in C#) in InstallShield. In Wix, this is no longer necessary because wix supports IIS deployment. Anyway, one of the code in the Custom Action uses the DirectoryEntry object to set...

Restricting URLs using Active Directory in Weblogic 10.3 - where to start?

Hi, We are looking to use an Active Directory server to restrict access to certain URLs in our Spring application on a Weblogic server and I have no idea where to start. The problem should be quite simple as I understand it, we have a simple app which has a number of URLs: <root>/page1.do <root>/page2.do <root>/page3.do etc. And an ...

Search AD with textbox value and return results as datatable

Currently I have a gridview bound to a datatable which is populated with groups from the AD. I need to be able to add search functionality so users can type in part of a group name and have the results display only groups that fit their search criteria. Here's what I have so far. <asp:TextBox ID="searchParam" runat="server"></asp:TextBo...

CFLDAP:- populate FULL data from Active directory, rather than a single userid or username.

I have a form field “Names” that gets populated from an Active Directory. I am using CFLDP to connect to the Active Directory. <cfldap action="QUERY" name="results" attributes="cn,sn,dn,department,mail,userid,etc." start="dc=##,dc=##,dc=##" filter="##=##" server="00.00.0004" username="me" password="meP...

Adding user permissions that may not yet exist depending on Active Directory

Hi, I'm using .NET to automatically create a user in Active Directory, afterwards I'm using WMI to execute shell commands on another server in the network to create a directory and set its permissions (with cacls) to grant the new user full access to this directory and it works. However, LDAP is running on two servers in the network and ...

Changing Active Directory user password

How can I change an Active Directory user password using Directory Services without knowing old password? ...

how to query changes in Active Directory including deleted objects?

I am using below code to query changes to users/OUs in AD. But it doesn't retrive any deleted objects, Any idea how to include deleted objects in this ? static void Main(string[] args) { BinaryFormatter bFormat = new BinaryFormatter(); byte[] cookie = null; string strFileName = "cookie.bin"; ...

Problem with starting web site on Vista & IIS 7 via .NET

Hello everybody! I need to get IIS web-site state programmatically via C#. I usually do it this way: DirectoryEntry DE = new DirectoryEntry( string.Format( "IIS://localhost/W3SVC/{0}", siteID ) ); Int32 serverState = (Int32)DE.Properties["ServerState"][0]; if ( serverState == IISHelper.MD_SERVER_STATE_STOPPED ) DE.Invoke("Start", ...

How do I check for presence of a bit in C# using AND?

How to I use logical operators to determine if a bit is set, or is bit-shifting the only way? I found this question that uses bit shifting, but I would think I can just AND out my value. For some context, I'm reading a value from Active Directory and trying to determine if it a Schema Base Object. I think my problem is a syntax issue...