Click here to Skip to main content
15,913,854 members
Home / Discussions / C#
   

C#

 
AnswerRe: did you Google Block Gmail?! Pin
Richard MacCutchan29-Mar-10 6:41
mveRichard MacCutchan29-Mar-10 6:41 
GeneralRe: did you Google Block Gmail?! Pin
Jassim Rahma29-Mar-10 11:30
Jassim Rahma29-Mar-10 11:30 
GeneralRe: did you Google Block Gmail?! [modified] Pin
Richard MacCutchan29-Mar-10 11:41
mveRichard MacCutchan29-Mar-10 11:41 
QuestionTreeview aftercheck Pin
Wannes Geysen29-Mar-10 5:21
Wannes Geysen29-Mar-10 5:21 
AnswerRe: Treeview aftercheck Pin
Kevin Marois29-Mar-10 5:28
professionalKevin Marois29-Mar-10 5:28 
AnswerRe: Treeview aftercheck Pin
Tarakeshwar Reddy29-Mar-10 6:44
professionalTarakeshwar Reddy29-Mar-10 6:44 
GeneralRe: Treeview aftercheck Pin
Wannes Geysen29-Mar-10 21:25
Wannes Geysen29-Mar-10 21:25 
QuestionGet list of groups for a given user using ActiveDirectory Pin
QuickDeveloper29-Mar-10 2:18
QuickDeveloper29-Mar-10 2:18 
Hi
I am getting the list of groups for a particular user using ActiveDirectory.
I am using the following code.

void GetUserDetailsFromAD()
{
  string _userName = Environment.UserName;
  string _userDomain = Environment.UserDomainName;

//Use given URL
   using (DirectoryEntry de = new DirectoryEntry(string.Format("LDAP://URL /OU=XYZ,DC={0},DC=XYZ,DC=XYZ,DC=com",_userDomain)))
            {
                   //Create a text file to write details
                    TextWriter tw = new StreamWriter("C:\\LDAP.txt");

                    de.AuthenticationType = AuthenticationTypes.Secure |AuthenticationTypes.ReadonlyServer;
                    using (DirectorySearcher search = new DirectorySearcher(de))
                    {
                        search.Filter = "(sAMAccountName=" + _userName + ")";
                        search.PropertiesToLoad.Add("displayName");
                        search.PropertiesToLoad.Add("memberof");
                        SearchResult result = search.FindOne();


                        if (result != null)
                        {
                            _displayName = result.Properties["displayname"][0].ToString();

                            //Loop through all the groups that user is part of
                            foreach (object item in result.Properties["memberof"])
                            {

                                 //Write the groups to a text file
                                tw.WriteLine(item.ToString());

                              //Check whether the group in which user is present starts with ABC
                                if (item.ToString().StartsWith("CN=ABC,DC=DEF"))
				{
					//user is member of ABC group
				}
				else
				{
				       //user is not member
				}
                            }
                        } 
                    }

                    tw.Close();
               
              
            }
}


When i run these program from my local machine(let's say machine A) ,the list of groups which _userName belongs to is populated in C:\\LDAP.txt file.However if i run this from another machine (machine B) in same network,only some groups are displayed ,not all.Eg:If machine A lists group 1,2,3,4 ,machine B lists only 1,2.

1)How can i know whether there are any restrictions in place on other system?(due to which all groups are not displayed)
2)How to check whether there any changes in network settings in the second machine with respect to Active Directory?

Please suggest.
"Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"


AnswerRe: Get list of groups for a given user using ActiveDirectory Pin
Abhinav S29-Mar-10 4:05
Abhinav S29-Mar-10 4:05 
QuestionAutomatic Server Shutdown Pin
FJJCENTU29-Mar-10 0:18
FJJCENTU29-Mar-10 0:18 
AnswerRe: Automatic Server Shutdown Pin
DaveyM6929-Mar-10 0:48
professionalDaveyM6929-Mar-10 0:48 
AnswerRe: Automatic Server Shutdown Pin
David Skelly29-Mar-10 1:56
David Skelly29-Mar-10 1:56 
AnswerRe: Automatic Server Shutdown Pin
Dave Kreskowiak29-Mar-10 3:43
mveDave Kreskowiak29-Mar-10 3:43 
QuestionRemoving items from list while performing operations on it Pin
xkrja29-Mar-10 0:17
xkrja29-Mar-10 0:17 
AnswerRe: Removing items from list while performing operations on it Pin
Keith Barrow29-Mar-10 0:47
professionalKeith Barrow29-Mar-10 0:47 
AnswerRe: Removing items from list while performing operations on it Pin
SeMartens29-Mar-10 0:48
SeMartens29-Mar-10 0:48 
Questionusing (SqlTransaction... ) Pin
Dewald29-Mar-10 0:12
Dewald29-Mar-10 0:12 
AnswerRe: using (SqlTransaction... ) Pin
Eddy Vluggen29-Mar-10 1:06
professionalEddy Vluggen29-Mar-10 1:06 
AnswerRe: using (SqlTransaction... ) Pin
Keith Barrow29-Mar-10 1:07
professionalKeith Barrow29-Mar-10 1:07 
AnswerRe: using (SqlTransaction... ) Pin
PSK_29-Mar-10 1:08
PSK_29-Mar-10 1:08 
GeneralRe: using (SqlTransaction... ) Pin
Dewald29-Mar-10 1:51
Dewald29-Mar-10 1:51 
GeneralRe: using (SqlTransaction... ) Pin
PSK_29-Mar-10 3:06
PSK_29-Mar-10 3:06 
GeneralRe: using (SqlTransaction... ) Pin
Dewald29-Mar-10 3:33
Dewald29-Mar-10 3:33 
AnswerRe: using (SqlTransaction... ) Pin
PIEBALDconsult29-Mar-10 4:14
mvePIEBALDconsult29-Mar-10 4:14 
GeneralRe: using (SqlTransaction... ) Pin
Dewald29-Mar-10 21:27
Dewald29-Mar-10 21:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.