Showing posts with label active directory. Show all posts
Showing posts with label active directory. Show all posts

Friday, December 2, 2011

Retrieving personal details from Active Directory

If you are programming in C#, you can access information held on Active Directory easily using the code below.

Below uses the libraries provided in DirectoryServices namespace to query the Active Directory such as a user's telephone number, email address, etc.  As you can see, it is very straight forward (at least compared with tutorials I have seen using LDAP)

<% System.DirectoryServices.DirectoryEntry directoryEntry
= principal.GetUnderlyingObject() as
System.DirectoryServices.DirectoryEntry; %>


<%: principal.DisplayName %>

Tel: <%: directoryEntry.Properties["telephoneNumber"].Value%>

Email: <%: directoryEntry.Properties["mail"].Value%>


Although it looks like classes in DirectoryServices are wrappers to equivalent LDAP calls, it is certainly a lot cleaner and easier to understand (in my opinions)

The full list of properties you can retrieve can be found on

Monday, October 31, 2011

Security Groups and Policies for a Windows User

In Windows environment, resources authorizations are usually done by checking a users security policy.  When you are writing a program, you often need to find out your own security group/ policy, so you can test your program with your own credentials.   However, it isn't always convenient to bother the system administrators to get details of your settings.

In a situation like this, you may want to try the tool gpresult

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/gpresult.mspx?mfr=true

With it, you can see settings about yourself.