473,378 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

DirectoryEntry

I wanted to know why the output is different & also like to know if C# i can
get the user name using DirectoryEntry > find.
C#
String myADSPath = ("WinNT://"+
Environment.MachineName+",computer");
DirectoryEntry m_drentry = new DirectoryEntry(myADSPath);
// "admin" is user name

DirectoryEntry m_secentry = m_drentry.Children.Find("admin");
m_txt1.Text = m_drentry.Name ; // Output is the name of Computer
Managed C++
String *adsPath = String::Format(S"WinNT://{0},computer",
Environment::MachineName);

DirectoryEntry *computerEntry = new DirectoryEntry(adsPath);
DirectoryEntry *userEntry = computerEntry->Children->Find (S"Admin");

m_txText->Text = userEntry->Name; //Output is the User Name
Nov 17 '05 #1
2 15879

"AbdSol" <Ab****@discussions.microsoft.com> wrote in message
news:A7**********************************@microsof t.com...
I wanted to know why the output is different & also like to know if C# i
can
get the user name using DirectoryEntry > find.
C#
String myADSPath = ("WinNT://"+
Environment.MachineName+",computer");
DirectoryEntry m_drentry = new DirectoryEntry(myADSPath);
// "admin" is user name

DirectoryEntry m_secentry = m_drentry.Children.Find("admin");
m_txt1.Text = m_drentry.Name ; // Output is the name of Computer
Managed C++
String *adsPath = String::Format(S"WinNT://{0},computer",
Environment::MachineName);

DirectoryEntry *computerEntry = new DirectoryEntry(adsPath);
DirectoryEntry *userEntry = computerEntry->Children->Find (S"Admin");

m_txText->Text = userEntry->Name; //Output is the User Name


There's an error in your C# code....

m_txt1.Text = m_drentry.Name ;
should be....
m_txt1.Text = m_secentry.Name;

Willy.
Nov 17 '05 #2
it works, thank you.

"Willy Denoyette [MVP]" wrote:

"AbdSol" <Ab****@discussions.microsoft.com> wrote in message
news:A7**********************************@microsof t.com...
I wanted to know why the output is different & also like to know if C# i
can
get the user name using DirectoryEntry > find.
C#
String myADSPath = ("WinNT://"+
Environment.MachineName+",computer");
DirectoryEntry m_drentry = new DirectoryEntry(myADSPath);
// "admin" is user name

DirectoryEntry m_secentry = m_drentry.Children.Find("admin");
m_txt1.Text = m_drentry.Name ; // Output is the name of Computer
Managed C++
String *adsPath = String::Format(S"WinNT://{0},computer",
Environment::MachineName);

DirectoryEntry *computerEntry = new DirectoryEntry(adsPath);
DirectoryEntry *userEntry = computerEntry->Children->Find (S"Admin");

m_txText->Text = userEntry->Name; //Output is the User Name


There's an error in your C# code....

m_txt1.Text = m_drentry.Name ;
should be....
m_txt1.Text = m_secentry.Name;

Willy.

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Querton Pierre-Benoit | last post by:
Hello, I develop a class to control IIS throw ADSI. But is seems that some method doesn't work with IIS. To be more clear ;) When I do the following code : DirectoryEntry w3svc = new...
2
by: Jessica | last post by:
When I create a single LDAP ActiveDirectory user and use DirectoryEntry.Invoke("SetPassword"...), the user is created and the password is set with no problems. However, when I try to add more...
0
by: Jessica | last post by:
I have a .Net 1.0 web service that uses a .Net 1.1 assembly to create users, change users' passwords, validate users, and remove users from an LDAP server. The 1.1 code uses the DirectoryServices...
2
by: Jay | last post by:
Please excuse the double post if your reader shows this as a new and as a reply. I can only use the web interface and it puts my reply 34 pages in. I am getting an error while trying to do a...
1
by: kenguil | last post by:
I'm hoping that this is the right group to post this to and that someone will have an answer to this. Environment: 1) Laptop joined to domain "foo.com", logged in using cached credentials 2)...
2
by: Chad Beckner | last post by:
Hi everyone, Sorry for cross posting, but I wanted to try and put this where it would be more visible to everyone... :-) I need to find a way to be able to search for entries in our ADS tree. ...
0
by: Mik | last post by:
Hi I am struggling to make a Web site/Web Directory copy work. I am using the System.DirectoryServices to connect to my localhost machine. There I have two web sites: Mysite1 (siteno 1) and...
6
by: huzz | last post by:
How do i create a directory entry to access a user's details such as their email address. Here are the object structure. domain.co.uk | |Computer Services - Type (OU) | |Cliff Saran - Type...
1
by: Magnus R | last post by:
In VB.Net I'm trying to find out the names of what Administrative Groups exist by querying Active Directory. The problem is when I try and query the children of the key LDAP://CN=Administrative...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.