|
Home > Archive > Microsoft Content Management Server > September 2005 > Authenticating CMS Context from a non-CMS page
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 |
Authenticating CMS Context from a non-CMS page
|
|
| Sivaji 2005-09-21, 7:48 am |
| In my application , i have used aspx page , which is not an MCMS Template .In
this page I am accessing ceratin postings and their contents based on
parameters and doing certain editing .Here I am not getting authenticated CMS
context , so I have to create a new CmsApplicationContext() object and call
AuthenticateAsUser() with UserID and Password passed as parameters .
Can I do the authentication for this non-CMS page in a better way
or is there way out to match HttppContext.Current of the non-CMS page with
CmsHttpContext.Current of the CMS-page from which this non-CMS page was
called?
Pls Help .
Thanx,
Sivaji
| |
| Stefan [MSFT] 2005-09-21, 7:48 am |
| Hi Sivaji,
if your pages are in a MCMS template project you could also use
CmsHttpContext. There is no need to use the CmsApplicationContext.
Cheers,
Stefan
--
This posting is provided "AS IS" with no warranties, and confers no rights
New to MCMS?
Check out this book: Building Websites Using MCMS: http://tinyurl.com/6zj44
----------------------
"Sivaji" <Sivaji@discussions.microsoft.com> wrote in message
news:68E7C557-1CC4-457F-B4C7-BC4E1AF03097@microsoft.com...
> In my application , i have used aspx page , which is not an MCMS Template
> .In
> this page I am accessing ceratin postings and their contents based on
> parameters and doing certain editing .Here I am not getting authenticated
> CMS
> context , so I have to create a new CmsApplicationContext() object and
> call
> AuthenticateAsUser() with UserID and Password passed as parameters .
> Can I do the authentication for this non-CMS page in a better way
> or is there way out to match HttppContext.Current of the non-CMS page with
> CmsHttpContext.Current of the CMS-page from which this non-CMS page was
> called?
> Pls Help .
> Thanx,
> Sivaji
>
| |
| Sivaji 2005-09-21, 7:48 am |
| Hi Stefan,
Thanx for ur reply. I used CmsHttpContext.Current and it worked.But my
requirement is the modification and updation of the posting contents , for
which I was using
cmsContext.AuthenticateAsUser("user","password",PublishingMode.Update);
and it was serving my purpose .But with CmsHttpContext , it fails because it
is not in the PublishingMode.Update mode.How can I set this mode to
PublishingMode.Update?
Thanx,
Sivaji
"Stefan [MSFT]" wrote:
> Hi Sivaji,
>
> if your pages are in a MCMS template project you could also use
> CmsHttpContext. There is no need to use the CmsApplicationContext.
>
> Cheers,
> Stefan
>
> --
> This posting is provided "AS IS" with no warranties, and confers no rights
>
> New to MCMS?
> Check out this book: Building Websites Using MCMS: http://tinyurl.com/6zj44
> ----------------------
>
>
> "Sivaji" <Sivaji@discussions.microsoft.com> wrote in message
> news:68E7C557-1CC4-457F-B4C7-BC4E1AF03097@microsoft.com...
>
>
>
| |
| Stefan [MSFT] 2005-09-21, 5:52 pm |
| Hi Sivaji,
you need to add NRMODE=Update to the querystring to achieve this.
Or you need to use application context. Using windows authentication you
could do it this way:
CmsApplicationContext cmsContext = new CmsApplicationContext();
WindowsIdentity ident = HttpContext.Current.User.Identity as
WindowsIdentity;
cmsContext.AuthenticateUsingUserHandle(ident.Token,PublishingMode.Update);
Using forms authentication you need to use AuthenticateAsUser.
Cheers,
Stefan
--
This posting is provided "AS IS" with no warranties, and confers no rights
New to MCMS?
Check out this book: Building Websites Using MCMS: http://tinyurl.com/6zj44
----------------------
"Sivaji" <Sivaji@discussions.microsoft.com> wrote in message
news:E6115935-EB21-4900-93BF-A2584B2F50EB@microsoft.com...[vbcol=seagreen]
> Hi Stefan,
> Thanx for ur reply. I used CmsHttpContext.Current and it worked.But my
> requirement is the modification and updation of the posting contents ,
> for
> which I was using
> cmsContext.AuthenticateAsUser("user","password",PublishingMode.Update);
> and it was serving my purpose .But with CmsHttpContext , it fails because
> it
> is not in the PublishingMode.Update mode.How can I set this mode to
> PublishingMode.Update?
> Thanx,
> Sivaji
>
> "Stefan [MSFT]" wrote:
>
| |
| Sivaji 2005-09-22, 2:48 am |
| Hi Stefan,
Thanx for ur suggestion .I could not use NRMODE=Update becoz I am clueless
about where and how this send this query string(also my aspx page is a
non-CMS page) as this one is undocumented CMS 2002 Help file.
I tried the second option and wrote code as u suggested ,but I am getting
NullReferenceException with WindowsIdentity ident set to null.The reason
looks like the statement:
WindowsIdentity ident = HttpContext.Current.User.Identity as WindowsIdentity;
does not help ident get any reference ,although
HttpContext.Current.User.Identity is not null.
Can u advise where I am going wrong?
Thanx,
Sivaji
"Stefan [MSFT]" wrote:
> Hi Sivaji,
>
> you need to add NRMODE=Update to the querystring to achieve this.
> Or you need to use application context. Using windows authentication you
> could do it this way:
>
> CmsApplicationContext cmsContext = new CmsApplicationContext();
> WindowsIdentity ident = HttpContext.Current.User.Identity as
> WindowsIdentity;
> cmsContext.AuthenticateUsingUserHandle(ident.Token,PublishingMode.Update);
>
> Using forms authentication you need to use AuthenticateAsUser.
>
> Cheers,
> Stefan
>
> --
> This posting is provided "AS IS" with no warranties, and confers no rights
>
> New to MCMS?
> Check out this book: Building Websites Using MCMS: http://tinyurl.com/6zj44
> ----------------------
>
>
> "Sivaji" <Sivaji@discussions.microsoft.com> wrote in message
> news:E6115935-EB21-4900-93BF-A2584B2F50EB@microsoft.com...
>
>
>
| |
| Stefan [MSFT] 2005-09-22, 7:49 am |
| Hi Sivaji,
as indicated this will only work with windows authentication. Not with guest
and not with forms authentication.
For the query string: just call your page with NRMODE=Update on the
querystring!
http://server/yourproject/youraspxp...x?NRMODE=Update
Cheers,
Stefan
--
This posting is provided "AS IS" with no warranties, and confers no rights
New to MCMS?
Check out this book: Building Websites Using MCMS: http://tinyurl.com/6zj44
----------------------
"Sivaji" <Sivaji@discussions.microsoft.com> wrote in message
news:038351C2-AB79-4BA4-B63F-70AB4C305F79@microsoft.com...[vbcol=seagreen]
> Hi Stefan,
> Thanx for ur suggestion .I could not use NRMODE=Update becoz I am clueless
> about where and how this send this query string(also my aspx page is a
> non-CMS page) as this one is undocumented CMS 2002 Help file.
> I tried the second option and wrote code as u suggested ,but I am getting
> NullReferenceException with WindowsIdentity ident set to null.The reason
> looks like the statement:
> WindowsIdentity ident = HttpContext.Current.User.Identity as
> WindowsIdentity;
> does not help ident get any reference ,although
> HttpContext.Current.User.Identity is not null.
> Can u advise where I am going wrong?
> Thanx,
> Sivaji
> "Stefan [MSFT]" wrote:
>
| |
| Sivaji 2005-09-22, 7:49 am |
| Hi Stefan,
Thanx for ur valuable advice.It helped me get what I wanted.
Sivaji
"Stefan [MSFT]" wrote:
> Hi Sivaji,
>
> as indicated this will only work with windows authentication. Not with guest
> and not with forms authentication.
>
> For the query string: just call your page with NRMODE=Update on the
> querystring!
>
> http://server/yourproject/youraspxp...x?NRMODE=Update
>
> Cheers,
> Stefan
>
> --
> This posting is provided "AS IS" with no warranties, and confers no rights
>
> New to MCMS?
> Check out this book: Building Websites Using MCMS: http://tinyurl.com/6zj44
> ----------------------
>
>
> "Sivaji" <Sivaji@discussions.microsoft.com> wrote in message
> news:038351C2-AB79-4BA4-B63F-70AB4C305F79@microsoft.com...
>
>
>
|
|
|
|
|