Re: ADSI and C#
- From: "Willy Denoyette [MVP]" <willy.denoyette@xxxxxxxxxx>
- Date: Mon, 2 May 2005 15:20:15 +0200
Missing Children in ...
userEntry.Find
Willy.
"Victor Pereira" <taintmode@xxxxxxxxxxxx> wrote in message
news:u1hR9YxTFHA.3280@xxxxxxxxxxxxxxxxxxxxxxx
> Hi Willy,
>
> I tried this "DirectoryEntry cEntry = userEntry.Find("admin"), but did'nt
> worked."
>
> Thanks for your reply,
>
> Victor
> "Willy Denoyette [MVP]" <willy.denoyette@xxxxxxxxxx> wrote in message
> news:elTPa7VTFHA.3952@xxxxxxxxxxxxxxxxxxxxxxx
>>
>> "Victor Pereira" <taintmode@xxxxxxxxxxxx> wrote in message
>> news:%235kncyPTFHA.2996@xxxxxxxxxxxxxxxxxxxxxxx
>> > Hi Willy,
>> > Thanks for your reply.. two MVPs aswering my questions.. that is a
> honor!
>> >
>> > But when you sad that i must create and delete i think your wrong and
> here
>> > is a function to proof it!
>> >
>> > void RenameUser(string hostname,string admusr)
>> >
>> > {
>> >
>> > try
>> >
>> > {
>> >
>> > DirectoryEntry entry = new DirectoryEntry("WinNT://" + hostname +
>> > ",computer");
>> >
>> > DirectoryEntry cEntry = entry.Children.Find("administrator");
>> >
>> > MessageBox.Show(cEntry.Path.ToString());
>> >
>> > cEntry.MoveTo(entry,admusr);
>> >
>> > cEntry.CommitChanges();
>> >
>> > }
>> >
>> > catch(Exception cc)
>> >
>> > {
>> >
>> > MessageBox.Show(cc.Message.ToString());
>> >
>> > }
>> >
>> > }
>> >
>> >
>> >
>> > Reguards,
>> >
>> > Victor Pereira MVP-WannaBe :-)
>> >
>>
>> Yes, but you probably know there are different ways to skin a cat, here
>> is
>> another one.
>>
>> DirectoryEntry cEntry = userEntry.Children.Find("administrator");
>> cEntry.Rename(admuser);
>> cEntry.CommitChanges();
>>
>> All depends what you realy wanna do, do you need a completely new entry
>> (that is a new SID) or do you need to keep the SID associated with a new
>> name?.
>> Note that someone who knows the SID of the original administrator, can
> also
>> find the name of the new administrator when using MoveTo and Rename.
>>
>>
>> Willy.
>>
>>
>
>
.
- References:
- Re: ADSI and C#
- From: Victor Pereira
- Re: ADSI and C#
- Prev by Date: Re: TreeView selecting nodes via code
- Next by Date: Re: How to create a datatable object from a datarow [].
- Previous by thread: Re: ADSI and C#
- Next by thread: Re: ADSI and C#
- Index(es):
Relevant Pages
|