How to Fix “The file exists. (Exception from HRESULT: 0×80070050)” error

Last month I tried to login into my SharePoint site but I got this error:
The file exists. (Exception from HRESULT: 0×80070050)

After 1day researches I solved this problem and in this article I want to show you how I did it.

This error occurred when I tried to install Microsoft Exchange Server in windows 2003 server. I need Exchange Server for my other purpose, but exchange server needed Active Directory (AD) to be installed. I'm using Windows 2003 server in my virtual PC and I'm installed SharePoint server 2007 on it. MOSS use Windows User and Groups for authorizing users and groups, and I didn't install AD before it.

However, after installing Active directory in my windows 2003, when I want to login into SharePoint sites, I'm confronting with above error.
It's a bad idea that you setup active directory after installing SharePoint server, but I do it! And I repair my wrong work with solving the problem.
Now I describe why and when this error occurs.

This error occurs when user's SID (System ID) has changed and SharePoint couldn't find new SID from database. When you try to setup Active Directory after installing MOSS, AD changes SID for all users. After Windows installed on your PC, Windows generate SID for host and users and assign unique SID for all of them automatically. When you install SharePoint in your machine, SharePoint stores user's information like SID, user's Site ID, permissions. in database. When you want to login to your site, SharePoint check user's SID from database, it will find out that active user's SID do not match with database store SID for that user, so SharePoint doesn't authorize user. And that error occurs.
Usually this error does not appear with AD changes, it may occurs when your network domain address changed or any other reason that may changes SID on SharePoint servers.
I found 3 ways to solve this problem:

  1. Opening Central Administrator/ Web Application in Site Collection Administrator. delete old users that you want login to site and then create that user again from this page. It causes to create new user with new SID in sharepoint database.
  2. From Central Administrator go to Application Management in Application Security open Policy for Web Application. Choose Add User and click next. Select a Username from Active Directory and enter in this section, then check Full Control option and select Account Operate as System for this user. Click Finish. (This step works if you can access to Central Administrator and AD is installed on your PC.)
    If you can access to Central Administrator page, both above steps are good to solve problem, but if you can't open this page like me, You should use next step to solving error.
  3. This step need more attention and is a technical way to solve this error.  I notice you to use this step with your responsibility!
    You need to run some Query in Database to changing SID for sites that have error.
    Open SQL Server from Management Studio, select New Query. Choose database for site that have error from database list. For example choose SharePoint_AdminContent_* ( (*) contain some number) database for Central Administrator Site, then Type below Query:

SELECT s.Id, w.FullUrl
FROM Sites s inner join Webs w on s.RootWebId = w.Id

After running query, Results show you all Site ID for your selected database.
Type next query in new query page and run it. Tp_login parameter contain username that you try to login into site and tp_Site ID contain number of Site ID from previous query result.
SELECT *
FROM UserInfo
WHERE tp_Login='Host/UserName'  and  tp_SiteID='8395827D-3815-470A-8537-409EDC54DA54'

Result shows SID for selected username. (In my site “Administrator” is username and “FAFA” is my hostname).now you should find SID for this user from Windows and replace it with database stored SID! For gain user's SID you need PStools utility. You can download it from here. After unzipping, from command prompt go to Pstools directory and type this command:
Psgetsid \hostname username
This command's result for my machine shown in image:

psTools command's result is in s-n-n-n format and you need to convert it to Hex format. There are some vbscript for converting both formats together, but after some research I found an experiential way to do it.
For example my administrator's SID is:
S-1-5-21-4064436893-45162017-310737895-500
And Hex format of it:
0×0105000000000005150000009D6242F2211EB102E77B8512F4010000
But how I converted it:

0x  Hex sign
01 )S-1(
05 (number of dashes – 2=7-2=5)
000000000005 (5 = 0×000000000005, big-endian)
15000000 (21 = 0×15000000, little-endian)
9D6242F2 (4064436893 = 0xF242629D, little-endian)
211EB102 (45162017 = 0×02B11E21, little-endian)
E77B8512 (310737895 = 0×12857BE7, little-endian)
F4010000 (500 = 0×01F4, little-endian)a

You can use calculator or other tools like Microsoft PowerCalc to converting Decimal number to hex.
Now you should to update database table with new SID that produce in step 4 .open query page and type this query :
UPDATE UserInfo
SET tp_SystemID = 0×010500000000000515000000B83B756A5D4EEB75EA44AFC7F4010000
FROM UserInfo
WHERE tp_ID = '1' and tp_guid='7AC7285B-ACEB-4942-AF7E-CD9191FDE5A4' and
      tp_Login='host/username'  and tp_SiteID = '8395827D-3815-470A-8537-409EDC54DA54'

I'm using other parameters like (tp_ID,tp_guid,..) in “WHERE” command to update correct row of User Info table. You can use these parameters with correct data from step 2 results.

Steps Completed and now you can browse your site with your Username without any errors.

 

See Original article in my Persian blog

See More Information about our community

< Arash >

Leave a Reply


How to Fix “The file exists. (Exception from HRESULT: 0×80070050)” error

Last month I tried to login into my SharePoint site but I got this error:
The file exists. (Exception from HRESULT: 0×80070050)

After 1day researches I solved this problem and in this article I want to show you how I did it.

This error occurred when I tried to install Microsoft Exchange Server in windows 2003 server. I need Exchange Server for my other purpose, but exchange server needed Active Directory (AD) to be installed. I'm using Windows 2003 server in my virtual PC and I'm installed SharePoint server 2007 on it. MOSS use Windows User and Groups for authorizing users and groups, and I didn't install AD before it.

However, after installing Active directory in my windows 2003, when I want to login into SharePoint sites, I'm confronting with above error.
It's a bad idea that you setup active directory after installing SharePoint server, but I do it! And I repair my wrong work with solving the problem.
Now I describe why and when this error occurs.

This error occurs when user's SID (System ID) has changed and SharePoint couldn't find new SID from database. When you try to setup Active Directory after installing MOSS, AD changes SID for all users. After Windows installed on your PC, Windows generate SID for host and users and assign unique SID for all of them automatically. When you install SharePoint in your machine, SharePoint stores user's information like SID, user's Site ID, permissions. in database. When you want to login to your site, SharePoint check user's SID from database, it will find out that active user's SID do not match with database store SID for that user, so SharePoint doesn't authorize user. And that error occurs.
Usually this error does not appear with AD changes, it may occurs when your network domain address changed or any other reason that may changes SID on SharePoint servers.
I found 3 ways to solve this problem:

  1. Opening Central Administrator/ Web Application in Site Collection Administrator. delete old users that you want login to site and then create that user again from this page. It causes to create new user with new SID in sharepoint database.
  2. From Central Administrator go to Application Management in Application Security open Policy for Web Application. Choose Add User and click next. Select a Username from Active Directory and enter in this section, then check Full Control option and select Account Operate as System for this user. Click Finish. (This step works if you can access to Central Administrator and AD is installed on your PC.)
    If you can access to Central Administrator page, both above steps are good to solve problem, but if you can't open this page like me, You should use next step to solving error.
  3. This step need more attention and is a technical way to solve this error.  I notice you to use this step with your responsibility!
    You need to run some Query in Database to changing SID for sites that have error.
    Open SQL Server from Management Studio, select New Query. Choose database for site that have error from database list. For example choose SharePoint_AdminContent_* ( (*) contain some number) database for Central Administrator Site, then Type below Query:

SELECT s.Id, w.FullUrl
FROM Sites s inner join Webs w on s.RootWebId = w.Id

After running query, Results show you all Site ID for your selected database.
Type next query in new query page and run it. Tp_login parameter contain username that you try to login into site and tp_Site ID contain number of Site ID from previous query result.
SELECT *
FROM UserInfo
WHERE tp_Login='Host/UserName'  and  tp_SiteID='8395827D-3815-470A-8537-409EDC54DA54'

Result shows SID for selected username. (In my site “Administrator” is username and “FAFA” is my hostname).now you should find SID for this user from Windows and replace it with database stored SID! For gain user's SID you need PStools utility. You can download it from here. After unzipping, from command prompt go to Pstools directory and type this command:
Psgetsid \hostname username
This command's result for my machine shown in image:

psTools command's result is in s-n-n-n format and you need to convert it to Hex format. There are some vbscript for converting both formats together, but after some research I found an experiential way to do it.
For example my administrator's SID is:
S-1-5-21-4064436893-45162017-310737895-500
And Hex format of it:
0×0105000000000005150000009D6242F2211EB102E77B8512F4010000
But how I converted it:

0x  Hex sign
01 )S-1(
05 (number of dashes – 2=7-2=5)
000000000005 (5 = 0×000000000005, big-endian)
15000000 (21 = 0×15000000, little-endian)
9D6242F2 (4064436893 = 0xF242629D, little-endian)
211EB102 (45162017 = 0×02B11E21, little-endian)
E77B8512 (310737895 = 0×12857BE7, little-endian)
F4010000 (500 = 0×01F4, little-endian)a

You can use calculator or other tools like Microsoft PowerCalc to converting Decimal number to hex.
Now you should to update database table with new SID that produce in step 4 .open query page and type this query :
UPDATE UserInfo
SET tp_SystemID = 0×010500000000000515000000B83B756A5D4EEB75EA44AFC7F4010000
FROM UserInfo
WHERE tp_ID = '1' and tp_guid='7AC7285B-ACEB-4942-AF7E-CD9191FDE5A4' and
      tp_Login='host/username'  and tp_SiteID = '8395827D-3815-470A-8537-409EDC54DA54'

I'm using other parameters like (tp_ID,tp_guid,..) in “WHERE” command to update correct row of User Info table. You can use these parameters with correct data from step 2 results.

Steps Completed and now you can browse your site with your Username without any errors.

 

See Original article in my Persian blog

See More Information about our community

< Arash >

Leave a Reply