P
poi
I query a Win2K domain controller to get the users inside a global
group. But my query only shows "name" and "(e-mail address removed)" , it does
not show it as
"domain\name". Where can I get the pre-windows 2000 domain nomenclature
to show?
DirectoryEntry userEntry = new DirectoryEntry( userSearch );
userEntry.Username = user;
userEntry.Password = password;
userEntry.AuthenticationType = AuthenticationTypes.FastBind;
DirectorySearcher userSearcher = new DirectorySearcher(userEntry);
userSearcher.SearchScope = SearchScope.Base;
userSearcher.PropertiesToLoad.Add("samAccountName");
userSearcher.PropertiesToLoad.Add("userPrincipalName");
SearchResult userResult = userSearcher.FindOne();
if ( userResult != null )
{
ResultPropertyCollection userProps = userResult.Properties;
if ( userProps.Contains( "samAccountName" ) == true )
{
ResultPropertyValueCollection propValue =
userProps["samAccountName"];
Console.WriteLine( propValue[0].ToString() );
}
if ( userProps.Contains( "userPrincipalName" ) == true )
{
ResultPropertyValueCollection propValue =
userProps["userPrincipalName"];
Console.WriteLine( propValue[0].ToString() );
}
}
Console.WriteLine();
Thanks.
group. But my query only shows "name" and "(e-mail address removed)" , it does
not show it as
"domain\name". Where can I get the pre-windows 2000 domain nomenclature
to show?
DirectoryEntry userEntry = new DirectoryEntry( userSearch );
userEntry.Username = user;
userEntry.Password = password;
userEntry.AuthenticationType = AuthenticationTypes.FastBind;
DirectorySearcher userSearcher = new DirectorySearcher(userEntry);
userSearcher.SearchScope = SearchScope.Base;
userSearcher.PropertiesToLoad.Add("samAccountName");
userSearcher.PropertiesToLoad.Add("userPrincipalName");
SearchResult userResult = userSearcher.FindOne();
if ( userResult != null )
{
ResultPropertyCollection userProps = userResult.Properties;
if ( userProps.Contains( "samAccountName" ) == true )
{
ResultPropertyValueCollection propValue =
userProps["samAccountName"];
Console.WriteLine( propValue[0].ToString() );
}
if ( userProps.Contains( "userPrincipalName" ) == true )
{
ResultPropertyValueCollection propValue =
userProps["userPrincipalName"];
Console.WriteLine( propValue[0].ToString() );
}
}
Console.WriteLine();
Thanks.