Re: Accessing SAM database using C#

From: Ollie (ollie_riches_at_NO_SPAMhotmail.com)
Date: 05/12/03


Date: Mon, 12 May 2003 11:18:23 +0100


Jim,

try this....

System.DirectoryServices.DirectoryEntry obDirEntry = new
System.DirectoryServices.DirectoryEntry("WinNT://" + "FB2");
System.DirectoryServices.DirectoryEntries entries = obDirEntry.Children;
System.DirectoryServices.DirectoryEntry obUser = entries.Find("testUser");
string name = obUser.Name;
System.DirectoryServices.PropertyCollection properties = obUser.Properties;
bool valid = properties.Contains("FullName");
string fullName = "";
System.DirectoryServices.PropertyValueCollection pvc = null;
if(valid)
{
pvc = properties["FullName"];
fullName = (string)pvc.Value;
}

"Jim" <jim@jimmmm.com> wrote in message
news:O8SOupGGDHA.2248@TK2MSFTNGP10.phx.gbl...
> High I want to search for a user account that is stored in local or domain
> SAM database, I have been able to search against Active Directory but
would
> like to be able to do the same against the SAM database using the
> System.DirectoryServices namespace?
>
> Can anyone provide me with a sample or tell me why the following does not
?
>
> System.DirectoryServices.DirectoryEntry dirRoot = new
> System.DirectoryServices.DirectoryEntry("WinNT://localhost");
>
> string nameContext =
> dirRoot.Invoke("GET","defaultNamingContext").ToString();
>
> System.DirectoryServices.DirectoryEntry dirRootPath = null;
> dirRootPath = new System.DirectoryServices.DirectoryEntry("WinNT://"+
> m_nameContext);
>
> System.DirectoryServices.DirectorySearcher dirSearcher = new
> System.DirectoryServices.DirectorySearcher(dirRootPath);
>
> dirSearcher.Filter = m_SAMAccountName + username;
> System.DirectoryServices.SearchResultCollection dirResults =
> dirSearcher.FindAll();
> if(dirResults.Count != 1)
> return null;
> ....
> ....
>
> Cheers
>
> Jim
>
>



Relevant Pages

  • Re: Integer to string conversion
    ... I think Jim probably has the best solution but we haven't covered ... templates yet and they seem very confusing, ... I'm trying to convert an integer into a string. ... char buf; ...
    (comp.lang.c)
  • Re: Speed this up for me, please
    ... Many thanks Jim. ... Function Sinfo_R1(ByRef lookupKey As String, ByRef lookupVal As String, _ ... Dim rng As Excel.Range ... The first row of the sheet contains titles for the columns. ...
    (microsoft.public.excel.programming)
  • Re: searching all members of a pds using wildcards
    ... The CA-PDSMAN String Scan and Replace facility allows you to do ... You can specify wildcard character or pattern ... The facility executes online via the EZYEDIT ISPF Productivity Platform, ... Behalf Of Jim McAlpine ...
    (bit.listserv.ibm-main)
  • Re: Re: Re: SATA problems
    ... Jim wrote: ... then for lsmod, I got a long string of files/modules, with "size" and ...
    (Debian-User)
  • Re: Whats the error?
    ... Hello Jim, ... > (If I declare ASCIIZ filename in FILE_START ... Sorry, but a string on the command-line is normally terminated by a 0Dh, not ... Maybe you should change the above jump to JBE, ...
    (alt.lang.asm)