473,387 Members | 1,590 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

logonuser api

Hi,
i need to use logonuser api in c# for windows 2000.
Logonuser api is working fine in windowsXp,Windows2003 server.in

windows 2000 for running logonuser api we need SE_TCB_NAME

Privilege(act as part of operating system).i need to set the

SE_TCB_NAME Privilege programatically with out restarting the

system for the privilege to take effect.
My program need is to check the username,password provided by the

user matches with windows username,password.Is there any other way

to check windows username,password other than using logonuser
Please help me out to solve the problem

Jan 3 '06 #1
3 8177

<pl**********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hi,
i need to use logonuser api in c# for windows 2000.
Logonuser api is working fine in windowsXp,Windows2003 server.in

windows 2000 for running logonuser api we need SE_TCB_NAME

Privilege(act as part of operating system).i need to set the

SE_TCB_NAME Privilege programatically with out restarting the

system for the privilege to take effect.
My program need is to check the username,password provided by the

user matches with windows username,password.Is there any other way

to check windows username,password other than using logonuser
Please help me out to solve the problem


If all you need is credential checking, you can use the
NetUserChangePassword API without changing the actual password.
Note that this may return an error code because of local or domain password
policy constraints!!!.
For instance if the local password policy "Minimum password age" is > 0, the
call will return with an error code 1327, but that means that the
credentials are valid but you can't change the password because of policy
constraints, so be carefull with error checking.
[DllImport("netapi32", CharSet=CharSet.Unicode, SetLastError=true)]
static extern int NetUserChangePassword(
[MarshalAs(UnmanagedType.LPWStr)] string domain,
[MarshalAs(UnmanagedType.LPWStr)] string user,
[MarshalAs(UnmanagedType.LPWStr)] string oldpassword,
[MarshalAs(UnmanagedType.LPWStr)] string newpassword);
// where domain is the domain name or a machine name (eg. local machine name
for local accounts)
int ret = NetUserChangePassword(.....);
if (ret != 0) // if failed
{
}
// success
....

Willy.
Jan 3 '06 #2
Thanks Willy Denoyette for your immediate reply.
I am already using NetUserChangePassword in my program,but i forget to
trap the error 1327.thanks for your valuable information.Is there any
chance for the password corruption if anything goes wrong while
executing NetUserChangePassword call.Is it possible to use some other
services to check windows username,password

Regards,
mani

Willy Denoyette [MVP] wrote:
<pl**********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hi,
i need to use logonuser api in c# for windows 2000.
Logonuser api is working fine in windowsXp,Windows2003 server.in

windows 2000 for running logonuser api we need SE_TCB_NAME

Privilege(act as part of operating system).i need to set the

SE_TCB_NAME Privilege programatically with out restarting the

system for the privilege to take effect.
My program need is to check the username,password provided by the

user matches with windows username,password.Is there any other way

to check windows username,password other than using logonuser
Please help me out to solve the problem


If all you need is credential checking, you can use the
NetUserChangePassword API without changing the actual password.
Note that this may return an error code because of local or domain password
policy constraints!!!.
For instance if the local password policy "Minimum password age" is > 0, the
call will return with an error code 1327, but that means that the
credentials are valid but you can't change the password because of policy
constraints, so be carefull with error checking.
[DllImport("netapi32", CharSet=CharSet.Unicode, SetLastError=true)]
static extern int NetUserChangePassword(
[MarshalAs(UnmanagedType.LPWStr)] string domain,
[MarshalAs(UnmanagedType.LPWStr)] string user,
[MarshalAs(UnmanagedType.LPWStr)] string oldpassword,
[MarshalAs(UnmanagedType.LPWStr)] string newpassword);
// where domain is the domain name or a machine name (eg. local machine name
for local accounts)
int ret = NetUserChangePassword(.....);
if (ret != 0) // if failed
{
}
// success
...

Willy.


Jan 3 '06 #3
No framework solution unless you are using v2.0 of the framework.

Willy.
<pl**********@gmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
Thanks Willy Denoyette for your immediate reply.
I am already using NetUserChangePassword in my program,but i forget to
trap the error 1327.thanks for your valuable information.Is there any
chance for the password corruption if anything goes wrong while
executing NetUserChangePassword call.Is it possible to use some other
services to check windows username,password

Regards,
mani

Willy Denoyette [MVP] wrote:
<pl**********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
> Hi,
> i need to use logonuser api in c# for windows 2000.
> Logonuser api is working fine in windowsXp,Windows2003 server.in
>
> windows 2000 for running logonuser api we need SE_TCB_NAME
>
> Privilege(act as part of operating system).i need to set the
>
> SE_TCB_NAME Privilege programatically with out restarting the
>
> system for the privilege to take effect.
> My program need is to check the username,password provided by the
>
> user matches with windows username,password.Is there any other way
>
> to check windows username,password other than using logonuser
> Please help me out to solve the problem
>


If all you need is credential checking, you can use the
NetUserChangePassword API without changing the actual password.
Note that this may return an error code because of local or domain
password
policy constraints!!!.
For instance if the local password policy "Minimum password age" is > 0,
the
call will return with an error code 1327, but that means that the
credentials are valid but you can't change the password because of policy
constraints, so be carefull with error checking.
[DllImport("netapi32", CharSet=CharSet.Unicode, SetLastError=true)]
static extern int NetUserChangePassword(
[MarshalAs(UnmanagedType.LPWStr)] string domain,
[MarshalAs(UnmanagedType.LPWStr)] string user,
[MarshalAs(UnmanagedType.LPWStr)] string oldpassword,
[MarshalAs(UnmanagedType.LPWStr)] string newpassword);
// where domain is the domain name or a machine name (eg. local machine
name
for local accounts)
int ret = NetUserChangePassword(.....);
if (ret != 0) // if failed
{
}
// success
...

Willy.

Jan 3 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Nimi | last post by:
When I run my application , the LogonUser method fails the exception is "LogonUser failed with error code :1314". I know the error is because of some privileges . I am using Windows 2000 sp4. I...
1
by: Rich | last post by:
I am running IIS6 on a Win2k3 server. I have an ASP.Net app (C#) that a user logs into and then I use LogonUser to validate them and log them onto the server. I have Windows Authentication ONLY...
3
by: Zeno Lee | last post by:
I'm trying to authenticate a user against a windows network. I want it to work across any kind of windows network from NT 4.0 up to Windows 2003 ADS. So far I've been using DirectoryEntry and...
3
by: Dan | last post by:
All, I am attempting to use the LogonUser API in an application. However, everytime I attempt to validate an account using this I get an error. The code is 1421 which has a description of...
2
by: BLiTZWiNG | last post by:
Having a few strage behaviours with this function, mainly in that when I try to logon to another computer with a different name/pass to the current user of the local machine, it tries to...
7
by: Jason | last post by:
I have an ASP.NET application with forms authentication. However, the login details correspond to a Windows account (I cannot use Windows authentication). If I obtain a token with LogonUser, can I...
9
by: schaf | last post by:
Hi NG ! I used the examples on the internet to create a Impersonate class which allows me to log on as another user. After logged on as the new user I could access files on a remote computer,...
1
by: Sajid | last post by:
I use LogonUser for user authentication against AD. When I run this in XP is works fine. But it gives me a Win32 Error 1314 (ERROR_PRIVILEGE_NOT_HELD) in Win 2000. Any idea why and how do I solve...
6
by: nild | last post by:
Hello i have a strange problem. I'm using LogonUser to impersonate the user under which my program must run. On Win XP or Server 2003 it works. But on 2000 it doesn't. So i found out, to set...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.