I want to get a list of users from a specific AD group. I use this
code:
*************** *************** *************** *************** *************** *************
SearchResult result;
DirectorySearch er search = new DirectorySearch er();
search.Filter = String.Format(" (cn={0})", groupName);
search.Properti esToLoad.Add("m ember");
result = search.FindOne( );
ArrayList userNames = new ArrayList();
if (result != null)
{
for (int counter = 0; counter <
result.Properti es["member"].Count; counter++)
{
string user = (string)result. Properties["member"][counter];
userNames.Add(u ser);
}
}
*************** *************** *************** *************** *************** *************
When the code is finished user string = "CN=Egholm Jacob (DFDS
A/S),OU=Developme nt,OU=IT,OU=DFD S AS,DC=dk,DC=dfd s,DC=root"
But what I want to do is getting information like givenName,
displayName etc. from the user.
What shall I do? 5 9623
You should load the givenName and displayName property from the AD.
string[] props = {"givenName ", "displayNam e", ".."};
search.Properti esToLoad.AddRan ge(props);
....
Willy.
<eg****@gmail.c om> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.com.. . I want to get a list of users from a specific AD group. I use this code:
*************** *************** *************** *************** *************** ************* SearchResult result; DirectorySearch er search = new DirectorySearch er(); search.Filter = String.Format(" (cn={0})", groupName); search.Properti esToLoad.Add("m ember"); result = search.FindOne( );
ArrayList userNames = new ArrayList(); if (result != null) { for (int counter = 0; counter < result.Properti es["member"].Count; counter++) { string user = (string)result. Properties["member"][counter]; userNames.Add(u ser); } }
*************** *************** *************** *************** *************** *************
When the code is finished user string = "CN=Egholm Jacob (DFDS A/S),OU=Developme nt,OU=IT,OU=DFD S AS,DC=dk,DC=dfd s,DC=root"
But what I want to do is getting information like givenName, displayName etc. from the user. What shall I do?
Thanks for your reply. I have change my code to this:
*************** *************** *************** *************** *************** **************
SearchResult result;
DirectorySearch er search = new DirectorySearch er();
search.Filter = String.Format(" (cn={0})", groupName);
search.Properti esToLoad.Add("m ember");
search.Properti esToLoad.Add("d isplayName");
result = search.FindOne( );
ArrayList userNames = new ArrayList();
if (result != null)
{
for (int counter = 0; counter <
result.Properti es["member"].Count; counter++)
{
string user = (string)result. Properties["member"][counter];
string test =
(string)result. Properties["displayNam e"][counter];
userNames.Add(u ser);
}
}
*************** *************** *************** *************** *************** **************
The string variable test returns the name of the group and not the name
of the user in the group.
<eg****@gmail.c om> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
Thanks for your reply. I have change my code to this:
*************** *************** *************** *************** *************** **************
SearchResult result;
DirectorySearch er search = new DirectorySearch er();
search.Filter = String.Format(" (cn={0})", groupName);
search.Properti esToLoad.Add("m ember");
search.Properti esToLoad.Add("d isplayName");
result = search.FindOne( );
ArrayList userNames = new ArrayList();
if (result != null)
{
for (int counter = 0; counter <
result.Properti es["member"].Count; counter++)
{
string user = (string)result. Properties["member"][counter];
string test =
(string)result. Properties["displayNam e"][counter];
userNames.Add(u ser);
}
}
*************** *************** *************** *************** *************** **************
The string variable test returns the name of the group and not the name
of the user in the group.
If your cn denotes a "username", you should apply the following filter.
src.Filter = "(objectCategor y=user)";
also, you should not use a for loop to iterate, use foreach instead.
Willy.
Hello Willy
I have change my code (look below), but it still dosen't work.
*************** *************** *************** *************** *************** **************
DirectoryEntry searchRoot = new DirectoryEntry( @"LDAP://dfds.root");
DirectorySearch er search = new DirectorySearch er(searchRoot);
search.Filter = "(&(cn=Grou p CFS Handlers)(objec tCategory=user) )";
search.Properti esToLoad.Add("s amaccountname") ;
foreach (SearchResult res in search.FindAll( ))
{
string dummy = res.Properties["samaccountname "].ToString();
}
*************** *************** *************** *************** *************** **************
I want to list all the users in the group "Group CFS Handlers", but
search.FindAll( ) returns 0 results. I just checked the AD and the group
"Group CFS Handlers" contain one user.
I you have any idea what I do wrong, please let my know. I believe it
has something to do with my filter, but I don't know what.
Hello Willy
I have change my code (look below), but it still dosen't work.
*************** *************** *************** *************** *************** **************
DirectoryEntry searchRoot = new DirectoryEntry( @"LDAP://dfds.root");
DirectorySearch er search = new DirectorySearch er(searchRoot);
search.Filter = "(&(cn=Grou p CFS Handlers)(objec tCategory=user) )";
search.Properti esToLoad.Add("s amaccountname") ;
foreach (SearchResult res in search.FindAll( ))
{
string dummy = res.Properties["samaccountname "].ToString();
}
*************** *************** *************** *************** *************** **************
I want to list all the users in the group "Group CFS Handlers", but
search.FindAll( ) returns 0 results. I just checked the AD and the group
"Group CFS Handlers" contain one user.
I you have any idea what I do wrong, please let my know. I believe it
has something to do with my filter, but I don't know what. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: scott289 |
last post by:
Getting the lists of users in a given Domain Group?
For example, our Network people have created a group called MyAppUsers,
and have added certain Users to this group. I need to get a list of
these users by pasing in the name of the Group. Is that possible?
|
by: BobTheDatabaseBoy |
last post by:
.... got: win2K, v8.1.6
login to win2K is to the network: user; bob13, domain; foo
it's a win2K domain.
i then login to my local db as db2admin. LIST APPLICATIONS
fails with security error. tells me bob13 doesn't have the
rights. bob13 has all rights in CC user maintenance. bob13
is member of Administrators in win2K on the box. i'm not logged
in to DB2 as bob13, just the box(? domain).
|
by: Mike Turco |
last post by:
(This was also posted to comp.database.ms-access before I realized this was
the hep group.)
Lets say that my WinXP computer has two users: Michael and Kathryn. One or
the other logs into the computer and opens up an Access database (I happen
to be using 2002). There is no security on the database -- just click on the
shortcut and you're in.
I want to be able to determine who opened that database by knowing who
logged into the computer.
|
by: Rod |
last post by:
I have been working with ASP.NET 1.1 for quite a while now. For some
reason, opening some ASP.NET applications we wrote is producing the
following error message:
"The Web server reported the following error when attempting to create or
open the Web project located at the following URL:
'http://localhost/WebApplication1'. 'HTTP/1.1 500 Internal Server Error'."
|
by: Derek Martin |
last post by:
Using VB.Net, I would like to retrieve the currently logged in user's DN
from Active Directory. Alternatively, if, using WindowsIdentity, or
something similar, I would like to get the user's full name that is found on
the Workstation Locked screen between the ( )'s.
Does anyone know how to do that? The only constraint: no use of
ActiveDS.dll permitted by the design.
Many thanks!
Derek
| |
by: wqyuwss |
last post by:
Hi,
We have several core dumps in our product. These core dump can be
reproduced in the same place. That is system function call
std::basic_istream<char,std::char_traits<char>>::getline. The result of
pstack for the core dump is
> pstack core | c++filt
|
by: Mike Spike |
last post by:
HI all,
How do I go about getting the permmisions of a file.
I have been able to get a list of access control rules and tell if they are
restricting or permiting a permmision but I cant tell which role / right
they are refering to:
I can get this type information by using the fileSystemSecurity object and
pointing it to a file or folder:
|
by: shashank kadge |
last post by:
hi all,
i am trying to get local admin users and groups on a windows server.
here is the C# code that i am using
***************************************************************************************************
DirectoryEntry AD = new DirectoryEntry("WinNT://" + sServerName +
",Computer",UserName,Password);
DirectoryEntry admGroup = AD.Children.Find("Administrators", "Group");
object members = admGroup.Invoke("Members", null);
...
|
by: Michael Howes |
last post by:
I'm writing a utility to manage a machines *local* accounts in c#
I am getting all the users in a specific Group just fine but when I
want to get some of the information on each user from their Properties
collection I can't get the properties on some users.
For example, I get all the users that are part of my machines
Administrators Group. I get get the properties of the built in local
Administrator account and some local IT account,...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |