Microsoft Content Management Server - Posting display name

This is Interesting: Free IT Magazines  
Home > Archive > Microsoft Content Management Server > October 2004 > Posting display name





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Posting display name
Randall

2004-10-07, 5: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

AC

2004-10-07, 5: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
>



Randall

2004-10-07, 5: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 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...
>
>
>

Stefan [MSFT]

2004-10-08, 7:47 am

Hi Randall,

are you logged in as CMS admin or as local admin?
You need to be logged in as CMS admin.

Cheers,
Stefan.

--
This posting is provided "AS IS" with no warranties, and confers no rights.

MCMS FAQ:
http://download.microsoft.com/downl...6a/MCMS+2002+-+(complete)+FAQ.htm
MCMS Blog: http://blogs.msdn.com/stefan_gossner/category/4983.aspx
MCMS Sample Code:
http://www.gotdotnet.com/community/...t+S
erver

MCMS Whitepapers and other docs:
http://blogs.msdn.com/stefan_gossne...2/07/41859.aspx
--------------------------------


"Randall" <Randall@discussions.microsoft.com> wrote in message
news:F1A4670C-99D8-4DB6-90A7-75F63F6EA8CE@microsoft.com...[vbcol=seagreen]
> 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:
>
someone[vbcol=seagreen]
it[vbcol=seagreen]
setup[vbcol=seagreen]
in[vbcol=seagreen]
website[vbcol=seagreen]
way[vbcol=seagreen]
to[vbcol=seagreen]


Randall

2004-10-08, 5:48 pm

Hello Stefan,

Thanks for replying back to me.
I am logged in as CMS admin. But it still doesn't allow me to do it.
Also is it possible to authenticate AppContext.AuthenticateAsCurrentUser(
PublishingMode.Update ) with the current user for the cms ?
I appreciate your help.

Regards,
Randall

"Stefan [MSFT]" wrote:

> Hi Randall,
>
> are you logged in as CMS admin or as local admin?
> You need to be logged in as CMS admin.
>
> Cheers,
> Stefan.
>
> --
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> MCMS FAQ:
> http://download.microsoft.com/downl...6a/MCMS+2002+-+(complete)+FAQ.htm
> MCMS Blog: http://blogs.msdn.com/stefan_gossner/category/4983.aspx
> MCMS Sample Code:
> http://www.gotdotnet.com/community/...t+S
erver

> MCMS Whitepapers and other docs:
> http://blogs.msdn.com/stefan_gossne...2/07/41859.aspx
> --------------------------------
>
>
> "Randall" <Randall@discussions.microsoft.com> wrote in message
> news:F1A4670C-99D8-4DB6-90A7-75F63F6EA8CE@microsoft.com...
> someone
> it
> setup
> in
> website
> way
> to
>
>
>

Stefan [MSFT]

2004-10-08, 5:48 pm

Hi Randall,

are you doing this inside a web application?
Then AuthenticateAsCurrentUser will not work.
This method only works in a console application.
Here is explanation and workaround:
http://download.microsoft.com/downl...6a/MCMS+2002+-+(complete)+FAQ.htm#7CE850B8-0F5A-4570-B8E7-3627A65E9056

Cheers,
Stefan

--
This posting is provided "AS IS" with no warranties, and confers no rights.

MCMS FAQ:
http://download.microsoft.com/downl...6a/MCMS+2002+-+(complete)+FAQ.htm
MCMS Blog: http://blogs.msdn.com/stefan_gossner/category/4983.aspx
MCMS Sample Code:
http://www.gotdotnet.com/community/...t+S
erver

MCMS Whitepapers and other docs:
http://blogs.msdn.com/stefan_gossne...2/07/41859.aspx
--------------------------------


"Randall" <Randall@discussions.microsoft.com> wrote in message
news:8E4FE78B-BCCF-411D-888B-C4D80A1742CC@microsoft.com...[vbcol=seagreen]
> Hello Stefan,
>
> Thanks for replying back to me.
> I am logged in as CMS admin. But it still doesn't allow me to do it.
> Also is it possible to authenticate AppContext.AuthenticateAsCurrentUser(
> PublishingMode.Update ) with the current user for the cms ?
> I appreciate your help.
>
> Regards,
> Randall
>
> "Stefan [MSFT]" wrote:
>
rights.[vbcol=seagreen]
http://download.microsoft.com/downl...6a/MCMS+2002+-+(complete)+FAQ.htm[vbcol=seagreen]
http://www.gotdotnet.com/community/...t+S
erver
[vbcol=seagreen]
running[vbcol=seagreen]
have[vbcol=seagreen]
passing[vbcol=seagreen]
in[vbcol=seagreen]
One[vbcol=seagreen]
have[vbcol=seagreen]
;[vbcol=seagreen]


Randall

2004-10-08, 5:48 pm

Stefan,

I need to use this code in the cms application where authentication mode is
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:

> Hi Randall,
>
> are you doing this inside a web application?
> Then AuthenticateAsCurrentUser will not work.
> This method only works in a console application.
> Here is explanation and workaround:
> http://download.microsoft.com/downl...6a/MCMS+2002+-+(complete)+FAQ.htm#7CE850B8-0F5A-4570-B8E7-3627A65E9056
>
> Cheers,
> Stefan
>
> --
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> MCMS FAQ:
> http://download.microsoft.com/downl...6a/MCMS+2002+-+(complete)+FAQ.htm
> MCMS Blog: http://blogs.msdn.com/stefan_gossner/category/4983.aspx
> MCMS Sample Code:
> http://www.gotdotnet.com/community/...t+S
erver

> MCMS Whitepapers and other docs:
> http://blogs.msdn.com/stefan_gossne...2/07/41859.aspx
> --------------------------------
>
>
> "Randall" <Randall@discussions.microsoft.com> wrote in message
> news:8E4FE78B-BCCF-411D-888B-C4D80A1742CC@microsoft.com...
> rights.
> http://download.microsoft.com/downl...6a/MCMS+2002+-+(complete)+FAQ.htm
> http://www.gotdotnet.com/community/...t+S
erver

> running
> have
> passing
> in
> One
> have
> ;
>
>
>

Randall

2004-10-08, 5:48 pm

Stefan,

Also How to create a console application ?

Regards,
Randall

"Stefan [MSFT]" wrote:

> Hi Randall,
>
> are you doing this inside a web application?
> Then AuthenticateAsCurrentUser will not work.
> This method only works in a console application.
> Here is explanation and workaround:
> http://download.microsoft.com/downl...6a/MCMS+2002+-+(complete)+FAQ.htm#7CE850B8-0F5A-4570-B8E7-3627A65E9056
>
> Cheers,
> Stefan
>
> --
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> MCMS FAQ:
> http://download.microsoft.com/downl...6a/MCMS+2002+-+(complete)+FAQ.htm
> MCMS Blog: http://blogs.msdn.com/stefan_gossner/category/4983.aspx
> MCMS Sample Code:
> http://www.gotdotnet.com/community/...t+S
erver

> MCMS Whitepapers and other docs:
> http://blogs.msdn.com/stefan_gossne...2/07/41859.aspx
> --------------------------------
>
>
> "Randall" <Randall@discussions.microsoft.com> wrote in message
> news:8E4FE78B-BCCF-411D-888B-C4D80A1742CC@microsoft.com...
> rights.
> http://download.microsoft.com/downl...6a/MCMS+2002+-+(complete)+FAQ.htm
> http://www.gotdotnet.com/community/...t+S
erver

> running
> have
> passing
> in
> One
> have
> ;
>
>
>

Stefan [MSFT]

2004-10-08, 5:48 pm

Hi Randall,

open VS.NET, choose C# or VB.NET and select Console Application.

Cheers,
Stefan.

--
This posting is provided "AS IS" with no warranties, and confers no rights.

MCMS FAQ:
http://download.microsoft.com/downl...6a/MCMS+2002+-+(complete)+FAQ.htm
MCMS Blog: http://blogs.msdn.com/stefan_gossner/category/4983.aspx
MCMS Sample Code:
http://www.gotdotnet.com/community/...t+S
erver

MCMS Whitepapers and other docs:
http://blogs.msdn.com/stefan_gossne...2/07/41859.aspx
--------------------------------


"Randall" <Randall@discussions.microsoft.com> wrote in message
news:02B1D587-224F-4C5F-8DD2-C8AD6FF2C321@microsoft.com...[vbcol=seagreen]
> Stefan,
>
> Also How to create a console application ?
>
> Regards,
> Randall
>
> "Stefan [MSFT]" wrote:
>
http://download.microsoft.com/downl...6a/MCMS+2002+-+(complete)+FAQ.htm#7CE850B8-0F5A-4570-B8E7-3627A65E9056[vbcol=seagreen]
rights.[vbcol=seagreen]
http://download.microsoft.com/downl...6a/MCMS+2002+-+(complete)+FAQ.htm[vbcol=seagreen]
http://www.gotdotnet.com/community/...t+S
erver
[vbcol=seagreen]
AppContext. AuthenticateAsCurrentUser([vbcol=seagree
n]
http://download.microsoft.com/downl...6a/MCMS+2002+-+(complete)+FAQ.htm[vbcol=seagreen]
http://www.gotdotnet.com/community/...t+S
erver
[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]


Stefan [MSFT]

2004-10-08, 5: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...6a/MCMS+2002+-+(complete)+FAQ.htm
MCMS Blog: http://blogs.msdn.com/stefan_gossner/category/4983.aspx
MCMS Sample Code:
http://www.gotdotnet.com/community/...t+S
erver

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...6a/MCMS+2002+-+(complete)+FAQ.htm#7CE850B8-0F5A-4570-B8E7-3627A65E9056[vbcol=seagreen]
rights.[vbcol=seagreen]
http://download.microsoft.com/downl...6a/MCMS+2002+-+(complete)+FAQ.htm[vbcol=seagreen]
http://www.gotdotnet.com/community/...t+S
erver
[vbcol=seagreen]
AppContext. AuthenticateAsCurrentUser([vbcol=seagree
n]
http://download.microsoft.com/downl...6a/MCMS+2002+-+(complete)+FAQ.htm[vbcol=seagreen]
http://www.gotdotnet.com/community/...t+S
erver
[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]


Randall

2004-10-08, 5:48 pm

Thanks Stefan.
I apprecite all your help.

Regards,
Randall

"Stefan [MSFT]" wrote:

> 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...6a/MCMS+2002+-+(complete)+FAQ.htm
> MCMS Blog: http://blogs.msdn.com/stefan_gossner/category/4983.aspx
> MCMS Sample Code:
> http://www.gotdotnet.com/community/...t+S
erver

> 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...
> is
> http://download.microsoft.com/downl...6a/MCMS+2002+-+(complete)+FAQ.htm#7CE850B8-0F5A-4570-B8E7-3627A65E9056
> rights.
> http://download.microsoft.com/downl...6a/MCMS+2002+-+(complete)+FAQ.htm
> http://www.gotdotnet.com/community/...t+S
erver

> AppContext.AuthenticateAsCurrentUser(
> http://download.microsoft.com/downl...6a/MCMS+2002+-+(complete)+FAQ.htm
> http://www.gotdotnet.com/community/...t+S
erver

> as
> you
> logging
> non-anon
> name
> postings.
> don't
> CmsApplicationContext();
> Posting
>
>
>

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com