"rcoco" <nc******@yahoo.cawrote in message
news:11*********************@e65g2000hsc.googlegro ups.com...
So you *are* trying to query ActiveDirectory...sigh!
Thanks Alexey,
I'm trying to put this code into c# I'm not so sure if it's wright.
the code in VB:
Dim DomainUser As String =
System.Security.Principal.WindowsIdentity.GetCurre nt.Name.Replace("\",
"/")
Dim ADEntry As New
System.DirectoryServices.DirectoryEntry("WinNT://" & DomainUser)
Dim FullName As String = ADEntry.Properties("FullName").Value
And I'm changing it in C# like this:
String DomainUser =
System.Security.Principal.WindowsIdentity.GetCurre nt.Name.Replace("\
\","/");
System.DirectoryServices.DirectoryEntry("WinNt://"& DomainUser);
String Fullname = ADEntry.Properties("FullName").Value;
But I'm getting these errors
1:'System.Security.Principal.WindowsIdentity.GetCu rrent()' denotes a
'method' which is not valid in the given context
That's because you've omitted the parentheses:
System.Security.Principal.WindowsIdentity.GetCurre nt().Name.Replace("\\","/");
2:Operator '&' cannot be applied to operands of type 'string' and
'string'
That's because the string concatenation operator in C# is +, not &
System.DirectoryServices.DirectoryEntry("WinNT://" + DomainUser);
3:The type or namespace name 'ADEntry' could not be found (are you
missing a using directive or an assembly reference?)
That's because you've forgotten to actually instantiate the ADEntry
object...
DirectoryEntry ADEntry = new
System.DirectoryServices.DirectoryEntry("WinNT://" + DomainUser);