 |
|
 |
|
10-07-04 10:47 PM
Hi all,
I have 10 different channels and they all have one posting by name Posting1.
We have to change the posting display name for all those postings. One way
of doing that is edit the posting and change its display name.
I was trying to write a code something like this so that we don't have to
edit all the postings.
CmsApplicationContext AppContext = new CmsApplicationContext();
AppContext.AuthenticateAsCurrentUser( PublishingMode.Update );
foreach(Channel ch in channelMain.Channels)
{
foreach(Posting p in ch.Postings)
{
if(p.Name=="posting1")
{
pTarget=p;
break;
}
}
Posting p1 =AppContext.Searches.GetByGuid(pTarget.Guid) as Posting ;
p1.DisplayName="new name";
}
AppContext.CommitAll();
AppContext.Dispose();
It works on my machine but didn't work on production machine.
I got the Login failed error.
Any suggestion?
I appreciate your help.
Regards,
Randall
[ Post a follow-up to this message ]
|
|
|
 |
|
 |
|
 |
|
10-07-04 10:47 PM
When you run it on your production machine... are you logged in as someone
who has access to the channels you're doing this to? If you're running it
trough the web and you have guest access, I doubt the guest user you setup
has been granted author rights to the channels.
Because you'r elogging in as "AuthenticateAsCurrentUser" you may have
issues. Look into using one of the other authentication mech. & passing in
an impersonated user (using a WindowsIdentity principal) or logging in
interactively to the box and running your script through a non-anon website
(or as a console app).
-AC
"Randall" <Randall@discussions.microsoft.com> wrote in message
news:5086AC6D-205D-47DB-AEEB-B6F07A0F75D2@microsoft.com...
> Hi all,
>
> I have 10 different channels and they all have one posting by name
> Posting1.
> We have to change the posting display name for all those postings. One way
> of doing that is edit the posting and change its display name.
>
> I was trying to write a code something like this so that we don't have to
> edit all the postings.
> CmsApplicationContext AppContext = new CmsApplicationContext();
> AppContext.AuthenticateAsCurrentUser( PublishingMode.Update );
> foreach(Channel ch in channelMain.Channels)
> {
> foreach(Posting p in ch.Postings)
> {
> if(p.Name=="posting1")
> {
> pTarget=p;
> break;
> }
> }
>
> Posting p1 =AppContext.Searches.GetByGuid(pTarget.Guid) as Posting ;
> p1.DisplayName="new name";
>
> }
> AppContext.CommitAll();
> AppContext.Dispose();
>
> It works on my machine but didn't work on production machine.
> I got the Login failed error.
>
> Any suggestion?
> I appreciate your help.
>
> Regards,
> Randall
>
[ Post a follow-up to this message ]
|
|
|
 |
|
 |
|
 |
|
10-07-04 10:47 PM
I am logged as an Admin on the production machine also.
How to go about the other approach?
I appreciate your help.
Regards,
Randall
"AC" wrote:
> When you run it on your production machine... are you logged in as someone
> who has access to the channels you're doing this to? If you're running it
> trough the web and you have guest access, I doubt the guest user you setup
> has been granted author rights to the channels.
>
> Because you'r elogging in as "AuthenticateAsCurrentUser" you may have
> issues. Look into using one of the other authentication mech. & passing i
n
> an impersonated user (using a WindowsIdentity principal) or logging in
> interactively to the box and running your script through a non-anon websit
e
> (or as a console app).
>
> -AC
>
> "Randall" <Randall@discussions.microsoft.com> wrote in message
> news:5086AC6D-205D-47DB-AEEB-B6F07A0F75D2@microsoft.com...
>
>
>
[ Post a follow-up to this message ]
|
|
|
 |
|
 |
|
 |
 |
|
 |
 |
|
 |
 |
|
 |
 |
|
 |
 |
|
 |
 |
|
 |
|
10-08-04 10:48 PM
Hi Randall,
as indicated in this article it will not work.
The only way to get this working with formsauthentication is by hard coding
user credentials.
Cheers,
Stefan.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
MCMS FAQ:
http://download.microsoft.com/downl...>
MCMS+2002+-+(complete)+FAQ.htm
MCMS Blog: http://blogs.msdn.com/stefan_gossner/category/4983.aspx
MCMS Sample Code:
http://www.gotdotnet.com/community/...nagement+Server
MCMS Whitepapers and other docs:
http://blogs.msdn.com/stefan_gossne...2/07/41859.aspx
--------------------------------
"Randall" <Randall@discussions.microsoft.com> wrote in message
news:065BA1DB-8DAC-4E5D-9D7A-E11E5D181547@microsoft.com...
> Stefan,
>
> I need to use this code in the cms application where authentication mode
is[vbcol=seagreen]
> forms.
> Will this work in that case?
> CmsApplicationContext cmsContext = new CmsApplicationContext();
> FormsIdentity ident = HttpContext.Current.User.Identity as FormsIdentity;
> cmsContext.AuthenticateUsingUserHandle(ident.Token,PublishingMode.Update);
>
> Now will it authenticate the logged user using the custom login form?
> Or is there any other way to do this?
> I appreciate your help.
>
> Regards,
> Randall
>
> "Stefan [MSFT]" wrote:
>
http://download.microsoft.com/downl...
+Server[vbcol=seagreen]
AppContext. AuthenticateAsCurrentUser([vbcol=seagree
n]
http://download.microsoft.com/downl...
+Server[vbcol=seagreen]
as[vbcol=seagreen]
you[vbcol=seagreen]
logging[vbcol=seagreen]
non-anon[vbcol=seagreen]
name[vbcol=seagreen]
postings.[vbcol=seagreen]
don't[vbcol=seagreen]
CmsApplicationContext();[vbcol=seagreen]
Posting[vbcol=seagreen]
[ Post a follow-up to this message ]
|
|
|
 |
|
 |
|
 |
|
|
|
Sponsored Links |
 |
 |
|
|
 |
All times are GMT. The time now is 12:20 PM. |
 |
|
|
 |
|
 |
|
|
 |
|
Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
|
|
|
|
Medical and Health forum | Computer Games Reviews | Graphics design forum
|
 |
|
 |
|